|
| 1 | +# Laravel Commands Package |
| 2 | + |
| 3 | +This Laravel package provides custom Artisan commands to simplify common tasks, such as creating symbolic links, deleting files, and generating Contracts and Responses with service provider bindings. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +1. Install the package via Composer: |
| 10 | + ```bash |
| 11 | + composer require eren/laravel-commands |
| 12 | + ``` |
| 13 | + |
| 14 | +2. (Optional) Publish the package configuration file: |
| 15 | + ```bash |
| 16 | + php artisan vendor:publish --provider="Eren\LaravelCommands\Providers\LCServiceProvider" |
| 17 | + ``` |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Available Commands |
| 22 | + |
| 23 | +### 1. `storage:link-custom` |
| 24 | + |
| 25 | +Create a symbolic link from `public/storage` to `storage/app/public`. If the link already exists, it will be skipped. Additionally, it creates an `uploads` folder if it doesn’t exist. |
| 26 | + |
| 27 | +#### Usage |
| 28 | +```bash |
| 29 | +php artisan storage:link-custom |
| 30 | +``` |
| 31 | + |
| 32 | +#### Behavior |
| 33 | +- Creates a symbolic link: `public/storage` → `storage/app/public`. |
| 34 | +- Creates an `uploads` folder in `storage/app` if it doesn’t exist. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +### 2. `files:delete-all` |
| 39 | + |
| 40 | +Delete all files from a specified directory. If no path is provided, it defaults to `storage/app/uploads`. |
| 41 | + |
| 42 | +#### Usage |
| 43 | +```bash |
| 44 | +php artisan files:delete-all {path?} |
| 45 | +``` |
| 46 | + |
| 47 | +#### Examples |
| 48 | +- Delete files from the default `uploads` folder: |
| 49 | + ```bash |
| 50 | + php artisan files:delete-all |
| 51 | + ``` |
| 52 | +- Delete files from a custom path: |
| 53 | + ```bash |
| 54 | + php artisan files:delete-all /path/to/folder |
| 55 | + ``` |
| 56 | + |
| 57 | +#### Behavior |
| 58 | +- Deletes all files in the specified directory. |
| 59 | +- If no path is provided, it defaults to `storage/app/uploads`. |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +### 3. `make:contract-response` |
| 64 | + |
| 65 | +Generate a Contract and Response class, and bind them in a service provider. |
| 66 | + |
| 67 | +#### Usage |
| 68 | +```bash |
| 69 | +php artisan make:contract-response {name} {--provider=HomeController1Provider} |
| 70 | +``` |
| 71 | + |
| 72 | +#### Examples |
| 73 | +- Generate `AuthContract` and `AuthResponse`: |
| 74 | + ```bash |
| 75 | + php artisan make:contract-response Auth |
| 76 | + ``` |
| 77 | +- Specify a custom service provider: |
| 78 | + ```bash |
| 79 | + php artisan make:contract-response Auth --provider=CustomServiceProvider |
| 80 | + ``` |
| 81 | + |
| 82 | +#### Behavior |
| 83 | +- Creates a Contract class in `app/Http/Contracts/{Name}Contract.php`. |
| 84 | +- Creates a Response class in `app/Http/Responses/{Name}Response.php`. |
| 85 | +- Binds the Contract and Response in the specified service provider (default: `HomeController1Provider`). |
| 86 | +- If the service provider doesn’t exist, it will be created automatically. |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## Configuration |
| 91 | + |
| 92 | +You can customize the behavior of the package by publishing the configuration file: |
| 93 | + |
| 94 | +1. Publish the configuration file: |
| 95 | + ```bash |
| 96 | + php artisan vendor:publish --provider="Eren\LaravelCommands\Providers\LCServiceProvider" |
| 97 | + ``` |
| 98 | + |
| 99 | +2. Update the configuration file located at `config/laravel-commands.php`. |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## Testing |
| 104 | + |
| 105 | +To run the package’s tests, use the following command: |
| 106 | +```bash |
| 107 | +./vendor/bin/phpunit |
| 108 | +``` |
| 109 | +or |
| 110 | +```bash |
| 111 | +php artisan test |
| 112 | +``` |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## Contributing |
| 117 | + |
| 118 | +Contributions are welcome! Please follow these steps: |
| 119 | + |
| 120 | +1. Fork the repository. |
| 121 | +2. Create a new branch for your feature or bugfix. |
| 122 | +3. Submit a pull request. |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## License |
| 127 | + |
| 128 | +This package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## Support |
| 133 | + |
| 134 | +If you encounter any issues or have questions, please open an issue on the [GitHub repository](https://github.com/noumanahmad448/laravel-commands). |
| 135 | + |
0 commit comments