/laravel-zero

A PHP Framework For Console Artisans

Primary LanguagePHPMIT LicenseMIT

StyleCI Status Build Status Quality Score Latest Stable Version Software License

This is a community project and not an "official" Laravel one

Laravel Zero was created and maintained by Nuno Maduro. Laravel Zero is a micro-framework that provides an elegant starting point for your next console application. Unofficial and customized version of Laravel optimized for building console/shell/command-line applications.

Installation & Usage

Requires PHP 7.1+

Via Laravel Zero Installer

composer global require consolidation/cgr && cgr laravel-zero/installer
laravel-zero new your-app-name

Or Simply create a new Laravel Zero project using Composer:

composer create-project --prefer-dist laravel-zero/laravel-zero your-app-name

Your Laravel Zero project will be then created in the your-app-name folder. Laravel Zero provides a default command placed in the app/HelloCommand.php file which will be executed by default. To execute it, run the following command in your app's directory:

php your-app-name

You can rename your app anytime by running the following command in your app directory:

php your-app-name app:rename new-name

You may review the documentation of the Artisan Console component on Laravel's Official Website.

Scheduler

Laravel Zero ships with the Task Scheduling of Laravel, to use it you may need to add the following Cron entry to your server:

* * * * * php /path-to-your-project/your-app-name schedule:run >> /dev/null 2>&1

You may define all of your scheduled tasks in the schedule method of the command:

    public function schedule(Schedule $schedule): void
    {
        $schedule->command(static::class)->everyMinute();
    }

Components

Laravel Zero allows you to install a Database component out of the box to push your console app to the next level. As you might have already guessed it is Laravel's Eloquent component that works with the same breeze in Laravel Zero environment too.

If you want to move files to multiple providers like AwsS3 and Dropbox, you may consider the Filesystem component.

To install the components run the following command in your Laravel Zero app directory:

php your-app-name component:install

This will allow you to select the component to install from the list of available components.

Configuration

The configuration of your console application goes in config\config.php. In this file, you should define your application's list of commands and your Laravel Service Providers in this file.

        'default-command' => App\Commands\HelloCommand::class,

        'commands' => [
            App\Commands\AddUserCommand::class,
        ],

Building a standalone application

Your Laravel Zero project, by default, allows you to build a standalone PHAR archive to ease the deployment or the distribution of your project.

php your-app-name app:build <your-build-name>

The build will provide a single phar archive, ready to use, containing all the code of your project and its dependencies.

Note that the generated file will still need a PHP installation respecting your project's requirements (PHP version, extensions, etc.) on the users' computers to be used. You will then be able to execute it directly:

./builds/<your-build-name>

or on Windows:

C:\application\path> php builds\<your-build-name>

Contributing

Thank you for considering to contribute to Laravel Zero. All the contribution guidelines are mentioned here.

Stay In Touch

You can have a look at the CHANGELOG & Releases for constant updates & detailed information about the changes. You can also follow the twitter account for latest announcements or just come say hi!: @laravelzero

License

Laravel Zero is an open-sourced software licensed under the MIT license.