Download the PHP package casperwilkes/laravel-helper_commands without Composer
On this page you can find all versions of the php package casperwilkes/laravel-helper_commands. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download casperwilkes/laravel-helper_commands
More information about casperwilkes/laravel-helper_commands
Files in casperwilkes/laravel-helper_commands
Package laravel-helper_commands
Short Description A set of useful artisan commands to help with development, deployment, and building your own commands quickly.
License MIT
Informations about the package laravel-helper_commands
Laravel Helper Commands
This is a package of simple artisan helper commands to help with the ease of development and some deployment of laravel. It also gives you the ability to write your own helper commands.
After installing this package, a new namespace will appear under artisan list
as helper
, and make
. New commands built with this package will appear
under helper
by default, unless otherwise specified by command creator.
TOC
- Installation
- Usage
- Clear
- Build
- Refresh
- DB
- Build Yor Own
- Command Helper
- Helper Trait
- Function List
- Publishing
Installation
There are a couple steps necessary to get the environment detector up and running.
Composer
To install the package through composer:
Usage
Included with the base package are a couple commands at your disposal.
clear
- This command is to clear out caches and configs
build
- This command builds the caches and configs
refresh
- This command will clear out caches and configs, then rebuild them
db
- This command is useful for quickly dumping and re-seeding your database
make:command-helper
- This command will build out a new helper
Back To Top ^
Clear
The clear command will help you do several things. It's biggest use is clearing away old config files and old caches.
Options
If you run the command without any arguments, the default will run.
(-c | --cache)
- Clears the cache file
{-d | --debug}
- Dumps the debugbar cache (if it exists)
{-b | --bootstrap}
- Dumps all the optimized views and bootstrap cache
{-l | --log}
- Compresses or deletes log files
{-s | --session}
- Compesses or deletes current sessions
{-x | --compress}
: [Default]- Compress option
{-a | --all}
: [Default]- Runs
-cdblsx
- Runs
Arguments
{delete}
: [Optional]- Used to delete instead of compress
Example Usage
-
To clear all the caches/configs:
-
To clear all caches/configs + delete logs and sessions
- To clear just the bootstrap & cache
Back To Top ^
Build
The build command is good for releasing, or seeing how the system works with all the caches in place.
Options
If you run the command without any arguments, the default will run.
{-c| --cache}
- Builds all the cache files for the system
{-r| --route}
- Builds all the route cache files
{-b| --bootstrap}
- Builds bootstraps (Optimizes)
-
{-a| --all}
: [Default]- Runs
-crb
Arguments
- Runs
- None
Example Usage
-
To build the route cache:
- To build route and cache, but not bootstrap:
Back To Top ^
Refresh
The refresh command runs a combination of Clear commands to quickly refresh your current environment.
Options
{-a | --all}
: [Default]- Runs
-bc
- Runs
{-b | --build}
- Builds and clears all caches/configs
{-c | --clear}
- Clears previous caches/configs
Arguments
- None
Example Usage
-
To clear and rebuild caches/configs:
- To clear just the configs:
Back To Top ^
DB
The db command runs a combination of db
commands.
Note:
- The commands run on simple options, if more advanced usage is necessary, use the default artisan
db
command. - Because of the sensitivity of this helper, unlike the other helpers, you must specify an option to run it
Options
{-f | --fresh}
- Runs fresh migrations
{-r | --refresh}
- Refreshes the database and migrations
{-w | --wipe}
- Wipes the database of tables
{-s | --seed}
- Seeds the database with all seeds
{-a | --all}
:- Runs
-rs
- Runs
Arguments
- None
Example Usage
-
To run a fresh migration and seed:
-
To refresh database and run seeds:
- To wipe the database, run fresh migrations, and seed
Back To Top ^
Building Your Own Helpers
Included in this package, is the ability to create your own helper commands easily.
Building your own helpers is incredibly easy. A Helper command is used to create a new helper class ready for you to build.
Note:
- This helper is contained within the Artisan
make
domain instead of thehelper
domain.
Command-Helper
Options
- none
Arguments
{name}
: [Required]- Name of the class. Best practice would be
HelperCamelCaseNameCommand
- Name of the class. Best practice would be
Example Usage
To make a new helper, run:
Back To Top ^
Custom Helpers
The make:command-helper
command will generate a new, ready to populate, command within the ./app/Console/Helper
directory.
The default signature is:
Just update this signature like you would any other command, replacing new-command
with your command name. With this implementation, there is no
need to register your new command with the Kernel.php
, it should be loaded automatically.
If the new Helper does not get loaded auto-magically, you'll need to update your autoloader classes in composer.
Run the following command to rebuild the class cache:
When your new class is created, it's automatically available in artisan too. So if you type php artisan list
, under the namespace helper
, you'll
see you new command waiting:
Also, when this class is created, it automatically initializes the HelperCommandTrait
within the commands handle
method.
The helper trait comes with some useful tools for quickly building out your own helper commands.
Back To Top ^
Helper Trait
The helper trait is a trait that comes with useful functions to help you build out your custom helper easily. When a new helper command is
generated, the init
method is automatically populated within the handle
. method.
This initialize method handles a variety of different functionality to help start up your development and execution.
Function List
These are the default functions in the HelperCommandTrait
init
getOptions
getArguments
adjustProcs
getProcs
finishLine
displayTimer
delete
compress
setProcs
Init
Init will:
- parse the signature line to grab arguments and options
- Hydrates the arguments array with incoming values
- Hydrates the options with array with incoming values
- Set the action count
- If
$progress
is passed, it will initialize a new progress bar
Back to Function List ^
getOptions
This function is a mixed bag.
- If nothing is passed, it will return all options (just the ones you specified), and removes the "default" options.
- If an option name is passed, it will return that option's value
- If an option name is passed, and the value does not exist, it will return the default value, or
null
if nothing is passed
Back to Function List ^
getArguments
Like getOptions
, this function is a mixed bag.
- If nothing is passed, it will return all arguments
- If an argument name is passed, it will return that argument's value
- If an argument name is passed, and the value does not exist, it will return the default value, or
null
if nothing is passed
Back to Function List ^
adjustProcs
This method is for adjusting procs (actions) for the progress bar. It will allow you to deduct or add procs to your initialized bar.
The procs are set after the options and arguments are parsed from the signature. For options that are true, a proc is added to the procs property. If you want to run extra processing, and let the user know, without having to ask for more information, you can adjust the proc with this method.
So, if you've got 3 options in your signature, and 2 are returned as true, then you'll have 2 procs.
But, if you want to adjust your output to run extra processing, and have the progress bar pick it up. You could use $this->adjustProcs(2)
, this
will add 2 extra procs to the progress bar.
If you want to remove a proc from the progres bar, you would use $this->adjustProcs(-2)
.
Back to Function List ^
getProcs
This method returns the current amount of procs (actions) that are to run.
Back to Function List ^
finishLine
This is purely and output function to display the total amount of execution time the command took, and the status of the progress bar
Back to Function List ^
displayTimer
This method will display the amount of time the command execution has taken. You can use this by itself if you don't wish to use the progress bar.
Back to Function List ^
delete
This function will take a file path, and remove that file from the filesystem.
Back to Function List ^
compress
This method will take a file path, and compress that file within the filesystem.
Back to Function List ^
setProcs
This function sets the initial procs for the command. You can hard-code the amount of actions directly with this method.
Back to Function List ^
Bar Advance
This is progress bar native function. Because we initialize the property bar as a progress bar, we have access to it's methods.
To advance the bar, call this within the command
Back to Function List ^
Adding Your Own Methods
In order to add your own methods to the HelperCommandTrait
, you will need to publish the vendor assets.
Back To Top ^
Publish
Publishing the HelperCommandTrait
is easy. Run the following artisan command to get the trait published to the ./app/Console/Helper/Custom
directory.
Publish Command
Publish using the tag:
After the trait is published, you may need to dump the composer autoloader and clear your caches:
Back To Top ^