Build your next Console Application Easily!.
Console applications like Composer is very convienient to use because all of its dependencies is packaged inside a phar file. You can easily move around the phar file or even remove the filename extension at all, making it looks like a single executable file. Creating PHAR files before though is never easy, and this boilerplate gives you a basic structure and tools to build one.
- Compresses all the dependency files inside the PHAR file. You can then distribute your CLI app in any machine w/o having to use Composer to fetch its dependencies.
- Powered by Symfony Console.
- Support for Eloquent ORM - YES!, you don't need to use Artisan console (not even Laravel ) just to use use Eloquent within your Console Application.
- Easy PHAR file compilation - it just takes one command to put all your source files and depedencies to one phar file : ./build.sh and that is all.
- Easy configuration via .env files. Love the dead simple .env files configuration of Laravel? Yes we have that here!
Try the Sample PHAR file
To give you a better idea of what you can produce out of this boilerplate, you can try a simple "Hello World" phar file that you can install in your local machine. All you need is PHP installed to run the sample file.
wget http://www.darwinbiler.com/console-app/sample/yourapp.phar sudo mv yourapp.phar /usr/local/bin/yourapp chmod +x /usr/local/bin/yourapp yourapp -V
Create a new project
composer create-project buonzz/console-app
Fetch the composer dependencies
In able to generate the a phar file, you need to install the box command. Follow the following instructions to install it
curl -LSs https://box-project.github.io/box2/installer.php | php sudo mv box.phar /usr/local/bin/box sudo chmod 755 /usr/local/bin/box box --version
In your php.ini file, make sure you have set phar.readonly settings to Off
Now you are all set!
and it will produce the phar file in dist folder.