Skip to content

Commit 82824a4

Browse files
v1.0
1 parent 855be3c commit 82824a4

File tree

14 files changed

+8102
-0
lines changed

14 files changed

+8102
-0
lines changed

.github/workflows/tests.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: Set up PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: "8.1"
21+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
22+
coverage: none
23+
24+
- name: Install dependencies
25+
run: composer install --prefer-dist --no-progress --no-suggest
26+
27+
# - name: Run tests
28+
# run: ./vendor/bin/phpunit

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage/*
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
9+
Homestead.json
10+
Homestead.yaml
11+
npm-debug.log
12+
yarn-error.log
13+
/storage/app/*
14+
/storage/logs/laravel.log
15+
.env.testing
16+
.editorconfig
17+
bootstrap/cache/*
18+
packages/*
19+
.env.dusk
20+
.phpunit.result.cache

README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+

composer.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "eren/laravel-commands",
3+
"description": "Laravel all custom commands for daily development",
4+
"type": "library",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"Eren\\LaravelCommands\\": "src/"
9+
}
10+
},
11+
"authors": [
12+
{
13+
"name": "Eren",
14+
"email": "nouman.laravel@outlook.com"
15+
}
16+
],
17+
"require": {
18+
"laravel/framework": "9.52.17"
19+
},
20+
"extra": {
21+
"laravel": {
22+
"providers": [
23+
"Eren\\LaravelCommands\\Providers\\LCServiceProvider"
24+
]
25+
}
26+
},
27+
"require-dev": {
28+
"phpunit/phpunit": "^9.6",
29+
"orchestra/testbench": "^7.47"
30+
},
31+
"version": "1.0",
32+
"minimum-stability": "stable"
33+
}

0 commit comments

Comments
 (0)