This package allows you to use the laravel make commands outside of a laravel application, this can be very useful for package development.
To install the package globally run composer global require michaeljennings/laravel-make
.
When composer has finished installing you should be able to laravel-make
in your command line and it should list all
of the available commands.
If you are on windows and it says laravel-make
is not a function then make sure your global composer .bin directory
is in the $PATH environment variable.
To install on a per project basis run composer require michaeljennings/laravel-make
.
Or add the package to you composer.json
file.
{
...
"require-dev": {
"michaeljennings/laravel-make": "~1.0",
},
...
}
Then run composer update
to install the package.
Once installed run vendor/bin/laravel-make
and you should see a list of all of the available commands.
By default the laravel commands try to place the new files within the app
directory and in the App
namespace, however
this is very rarely how a package is setup.
To get around this you can create a .laravel-make
file in the root of your package and define your package specific
configuration in it. This file works like a .env
file, a sample file is below, and then there is a description of each
configuration option underneath.
BASE_PATH=/src
BASE_NAMESPACE=Example\Package
USER_MODEL=Example\Package\Models\User
The base path that will be prepended to all files, excluding migrations and seeders.
Defaults to /app
BASE_PATH=/src
This is the root namespace that will be prepended to each class.
Defaults to 'App'
BASE_NAMESPACE=Example\Package
This option is a little strange. Some of the stubs need to the path to the user model for the application, by default
laravel tries to find this from the auth config file. As we don't have the auth config file available to us we have
to specify it in the .laravel-make
file.
Defaults to 'App\User'
USER_MODEL=Example\Auth\Models\User
The path the command files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Console/Commands'
CONSOLE_COMMAND_PATH=src/Commands
The namespace that will be prepended to all console commands.
Defaults to '{BASE_NAMESPACE}\Console\Commands'
CONSOLE_NAMESPACE=Example\Package\Commands
The path the controller files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Http/Controllers'
CONTROLLER_PATH=src/Controllers
The namespace that will be prepended to all controllers.
Defaults to '{BASE_NAMESPACE}\Http\Controllers'
CONTROLLER_NAMESPACE=Example\Package\Controllers
The path the event files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Events'
EVENT_PATH=src/Events
The namespace that will be prepended to all events.
Defaults to '{BASE_NAMESPACE}\Events'
EVENT_NAMESPACE=Example\Package\Events
The path the listener files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Listeners'
LISTENER_PATH=src/Listeners
The namespace that will be prepended to all listeners.
Defaults to '{BASE_NAMESPACE}\Listeners'
LISTENER_NAMESPACE=Example\Package\Listeners
The path the mail files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Mail'
MAIL_PATH=src/Mail
The namespace that will be prepended to all mail classes.
Defaults to '{BASE_NAMESPACE}\Mail'
MAIL_NAMESPACE=Example\Package\Mail
The path the middleware files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Middleware'
MIDDLWARE_PATH=src/Middleware
The namespace that will be prepended to all middleware classes.
Defaults to '{BASE_NAMESPACE}\Middleware'
MIDDLWARE_NAMESPACE=Example\Package\Middleware
The path the migration files should be stored in. By default this will prepend the base path.
Defaults to 'database/migrations'
MIGRATION_PATH=migrations
The path the model files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}'
MODEL_PATH=src/Models
The namespace that will be prepended to all models.
Defaults to '{BASE_NAMESPACE}\Models'
MODEL_NAMESPACE=Example\Package\Models
The path the notification files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Notifications'
NOTIFICATION_PATH=src/Notifications
The namespace that will be prepended to all notifications.
Defaults to '{BASE_NAMESPACE}\Notifications'
NOTIFICATION_NAMESPACE=Example\Package\Notifications
The path the policy files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Policies'
POLICY_PATH=src/Policies
The namespace that will be prepended to all policies.
Defaults to '{BASE_NAMESPACE}\Policies'
POLICY_NAMESPACE=Example\Package\Policies
The path the provider files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Providers'
PROVIDER_PATH=src/Providers
The namespace that will be prepended to all providers.
Defaults to '{BASE_NAMESPACE}\Providers'
PROVIDER_NAMESPACE=Example\Package\Providers
The path the request files should be stored in. By default this will prepend the base path.
Defaults to '{BASE_PATH}/Requests'
REQUEST_PATH=src/Requests
The namespace that will be prepended to all requests.
Defaults to '{BASE_NAMESPACE}\Requests'
REQUEST_NAMESPACE=Example\Package\Requests
The path the seeder files should be stored in. By default this will prepend the base path.
Defaults to 'database/seeds'
SEEDER_PATH=seeds