Table of Contents
- Running Commands
- Getting Help
- Built-In Commands
Console applications are great for administrative tasks and code generation. Apex is Opulence's own robust console kernel. With it, you can easily create your own console commands, display question prompts, and use HTML-like syntax for output styling.
To run commands, type
php apex COMMAND_NAME from the directory that Opulence is installed in.
To get help with any command, use the help command. There are a few different ways to call it:
php apex help COMMAND_NAME php apex COMMAND_NAME -h php apex COMMAND_NAME --help
A good place to start is to run
php apex in the directory you installed Opulence. This will list the commands registered to the console. Out of the box, a few commands come bundled with Apex:
Creates a file that lets the
Opulence\Framework\Http\Middleware\CheckMaintenanceMode middleware know to thrown a 503
HttpException, which renders a "Down for maintenance" response.
Displays the current application environment name, eg "Production" or "Development".
When you install Opulence, the default namespace is "Project". Use this command to change this to something more fitting to your particular project. This will update namespaces, bootstrapper names, and the composer.json PSR-4 settings.
Runs Opulence locally using the built-in PHP web server. You can change the domain and port using the
--port options, respectively.
Deletes the file that forces the application into maintenance mode.
This provides a wrapper around Composer's
dump-autoload command, and is useful when another command needs to dump the autoload after running.
A common task is updating composer and dumping the autoload. Instead of having to run these commands manually, just run
php apex composer:update.
The cryptography library uses a password, from which cryptographic keys are derived to encrypt and decrypt data. This command uses a CSPRNG to generate a password that can be used with the encryption library. Calling this will update the password that appears in config/environment/.env.app.php. Passing a
--show option will instead only show a new password, not update the config.
Opulence has an internal cache for several of its components:
If you add/remove/modify any of these components in your application, you must run this command to flush the internal cache. Otherwise, your changes may not take effect.
To make creating new classes as simple as possible, Apex supports several
make:* commands to generate class files:
They all accept a single argument: the name of the class to generate. If you input a fully-qualified class name, then that namespace and class name will be used. Otherwise, the default namespace will be used (eg controllers are under
This command rolls back all executed migrations.
This command runs all un-executed migrations.
This command creates a new UUID.
If you also use Opulence's HTTP kernel and view template, you can use this command to clear the view cache. This is handy for when you've made updates to your views.