Download the PHP package panchodp/laravel-actions without Composer
On this page you can find all versions of the php package panchodp/laravel-actions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-actions
Laravel Actions
Make your Laravel actions classes fast and in a simple way.
Compatibility
| Laravel | PHP | Package |
|---|---|---|
| 11.x | 8.3+ | ^2.x |
| 12.x | 8.3+ | ^2.x |
| 13.x | 8.3+ | ^2.x |
Installation
You can install the package via composer:
Configuration
Publish the configuration file:
This creates config/laravel-actions.php:
base_folder: Base folder where action classes are created. Defaults toActions(app/Actions).method_name: Method name generated in action classes. Defaults tohandle.
Customizing Stubs
You can publish and edit the stub templates used to generate action classes:
This publishes the 4 stubs to resources/stubs/vendor/laravel-actions/. Once published, the package will use your custom stubs instead of the defaults. You can customize each stub independently — any stub not found in your published directory will fall back to the package default.
Method Types
By default, Laravel Actions generates instance methods for better flexibility and dependency injection support. However, you can create static methods when needed for simpler usage.
Instance Methods (Default)
Static Methods
Usage
Interactive Mode
Run make:action without arguments to launch an interactive wizard:
Creating Actions
To create an action class, use the make:action command. You can specify the full path using forward slashes / or backslashes \ (Laravel-style syntax):
Basic action:
This creates a new action class in the app/Actions directory.
Action in a subfolder:
This creates the action in app/Actions/User/CreateAccount.php.
Action in nested subfolders:
This creates the action in app/Actions/User/Auth/Login.php.
Using backslashes (alternative syntax):
This creates the action in app/Actions/Admin/DeletePost.php.
The generated class will have a handle method where you can implement your action logic:
Flags
| Flag | Shortcut | Description |
|---|---|---|
--transaction |
-t |
Wraps the action body in a DB::transaction |
--user |
-u |
Injects User $user into the method |
--request |
-r |
Generates a Request class and injects it into the method |
--static |
-s |
Generates a static method instead of an instance method |
--force |
Overwrites the action if it already exists |
Shortcuts can be combined in any order, just like make:model:
Example output for --turs:
Other Userfull Commands:
You can show the Actions directory tree in the terminal with the following command:
This will display the structure of the app/Actions or the base directory specified in the config file, showing all action classes and their subdirectories.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.