|
1 | | - [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YNNLC9V28YDPN) |
| 1 | +# Laravel Terminal - Enhanced Version |
2 | 2 |
|
3 | | -# Laravel Terminal |
| 3 | +Laravel 11/12 compatible web terminal with full Composer support and Filament authentication. |
4 | 4 |
|
5 | | -[](https://styleci.io/repos/45892521) |
6 | | -[](https://travis-ci.org/recca0120/laravel-terminal) |
7 | | -[](https://packagist.org/packages/recca0120/terminal) |
8 | | -[](https://packagist.org/packages/recca0120/terminal) |
9 | | -[](https://packagist.org/packages/recca0120/terminal) |
10 | | -[](https://packagist.org/packages/recca0120/terminal) |
11 | | -[](https://packagist.org/packages/recca0120/terminal) |
12 | | -[](https://packagist.org/packages/recca0120/terminal) |
13 | | -[](https://scrutinizer-ci.com/g/recca0120/laravel-terminal/?branch=master) |
14 | | -[](https://scrutinizer-ci.com/g/recca0120/laravel-terminal/?branch=master) |
| 5 | +## Features |
15 | 6 |
|
16 | | -## Installation |
17 | | - |
18 | | -```bash |
19 | | -composer require recca0120/terminal --dev |
20 | | -``` |
21 | | - |
22 | | -OR |
23 | | - |
24 | | -Add Presenter to your composer.json file: |
25 | | - |
26 | | -```js |
27 | | -"require-dev": { |
28 | | - "recca0120/terminal": "^1.6.8" |
29 | | -} |
30 | | -``` |
31 | | -Now, run a composer update on the command line from the root of your project: |
32 | | - |
33 | | -``` |
34 | | -composer update |
35 | | -``` |
36 | | - |
37 | | -### Registering the Package |
| 7 | +- ✅ Laravel 11/12 compatibility |
| 8 | +- ✅ Full Composer support (all commands) |
| 9 | +- ✅ Smart Tinker with auto-fixes for quotes and namespaces |
| 10 | +- ✅ Filament authentication integration |
| 11 | +- ✅ Shared hosting compatible |
| 12 | +- ✅ No SSH required |
38 | 13 |
|
39 | | -Include the service provider within `app/config/app.php`. The service povider is needed for the generator artisan command. |
40 | | - |
41 | | -```php |
42 | | -'providers' => [ |
43 | | - ... |
44 | | - Recca0120\Terminal\TerminalServiceProvider::class, |
45 | | - ... |
46 | | -]; |
47 | | -``` |
| 14 | +## Installation |
48 | 15 |
|
49 | | -publish |
| 16 | +### 1. Install Package |
50 | 17 |
|
51 | | -```php |
52 | | -artisan vendor:publish --provider="Recca0120\Terminal\TerminalServiceProvider" |
| 18 | +```bash |
| 19 | +composer config repositories.enhanced-terminal vcs https://github.com/megavolkan/laravel-terminal |
| 20 | +composer require recca0120/terminal:dev-master |
53 | 21 | ``` |
54 | 22 |
|
| 23 | +### 2. Publish Configuration |
55 | 24 |
|
56 | | -### URL |
57 | | - |
58 | | -http://localhost/path/to/terminal |
59 | | - |
60 | | -### config |
61 | | - |
62 | | -```php |
63 | | -return [ |
64 | | - 'enabled' => env('APP_DEBUG'), |
65 | | - 'whitelists' => ['127.0.0.1', 'your ip'], |
66 | | - 'route' => [ |
67 | | - 'prefix' => 'terminal', |
68 | | - 'as' => 'terminal.', |
69 | | - // if you use laravel 5.1, remember to remove web middleware |
70 | | - 'middleware' => ['web'], |
71 | | - // if you need auth, you need use web and auth middleware |
72 | | - // 'middleware' => ['web', 'auth'] |
73 | | - ], |
74 | | - 'commands' => [ |
75 | | - \Recca0120\Terminal\Console\Commands\Artisan::class, |
76 | | - \Recca0120\Terminal\Console\Commands\ArtisanTinker::class, |
77 | | - \Recca0120\Terminal\Console\Commands\Cleanup::class, |
78 | | - \Recca0120\Terminal\Console\Commands\Find::class, |
79 | | - \Recca0120\Terminal\Console\Commands\Mysql::class, |
80 | | - \Recca0120\Terminal\Console\Commands\Tail::class, |
81 | | - \Recca0120\Terminal\Console\Commands\Vi::class, |
82 | | - // add your command |
83 | | - ], |
84 | | -]; |
85 | | - |
| 25 | +```bash |
| 26 | +php artisan vendor:publish --provider="Recca0120\Terminal\TerminalServiceProvider" |
86 | 27 | ``` |
87 | 28 |
|
88 | | -## Available Commands |
89 | | - |
90 | | -* artisan |
91 | | -* artisan tinker |
92 | | -* find |
93 | | -* mysql |
94 | | -* tail |
95 | | -* vi |
96 | | - |
97 | | -### Find |
98 | | - |
99 | | -not full support, but you can delete file use this function (please check file permission) |
| 29 | +### 3. Create Filament Auth Middleware |
100 | 30 |
|
101 | 31 | ```bash |
102 | | -find ./vendor -name tests -type d -maxdepth 4 -delete |
| 32 | +php artisan make:middleware FilamentTerminalAuth |
103 | 33 | ``` |
104 | 34 |
|
105 | | -## Add Your Command |
| 35 | +Add this content to `app/Http/Middleware/FilamentTerminalAuth.php`: |
106 | 36 |
|
107 | | -### Add Command Class |
108 | 37 | ```php |
109 | | -// src/Console/Commands/Mysql.php |
| 38 | +<?php |
110 | 39 |
|
111 | | -namespace Recca0120\Terminal\Console\Commands; |
| 40 | +namespace App\Http\Middleware; |
112 | 41 |
|
113 | | -use Illuminate\Console\Command; |
114 | | -use Illuminate\Foundation\Inspiring; |
115 | | -use Recca0120\Terminal\Contracts\TerminalCommand; |
| 42 | +use Closure; |
| 43 | +use Illuminate\Http\Request; |
| 44 | +use Symfony\Component\HttpFoundation\Response; |
116 | 45 |
|
117 | | -class Inspire extends Command implements TerminalCommand |
| 46 | +class FilamentTerminalAuth |
118 | 47 | { |
119 | | - /** |
120 | | - * The name and signature of the console command. |
121 | | - * |
122 | | - * @var string |
123 | | - */ |
124 | | - protected $signature = 'inspire'; |
125 | | - |
126 | | - /** |
127 | | - * The console command description. |
128 | | - * |
129 | | - * @var string |
130 | | - */ |
131 | | - protected $description = 'Display an inspiring quote'; |
132 | | - |
133 | | - /** |
134 | | - * Execute the console command. |
135 | | - * |
136 | | - * @return mixed |
137 | | - */ |
138 | | - public function handle() |
| 48 | + public function handle(Request $request, Closure $next): Response |
139 | 49 | { |
140 | | - $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); |
| 50 | + if (!auth()->check()) { |
| 51 | + return redirect('/admin/login'); |
| 52 | + } |
| 53 | + |
| 54 | + $user = auth()->user(); |
| 55 | + |
| 56 | + // Optional: Add role/permission checks |
| 57 | + /* |
| 58 | + if (!$user->hasRole('admin')) { |
| 59 | + return response('Access denied to terminal', 403); |
| 60 | + } |
| 61 | + */ |
| 62 | + |
| 63 | + return $next($request); |
141 | 64 | } |
142 | 65 | } |
143 | 66 | ``` |
144 | 67 |
|
145 | | -## ScreenShot |
| 68 | +### 4. Register Middleware |
146 | 69 |
|
147 | | -### Available Commands |
148 | | -```bash |
149 | | -$ help |
150 | | -``` |
151 | | - |
| 70 | +In `bootstrap/app.php`, add: |
152 | 71 |
|
153 | | -### Artisan List |
154 | | -```bash |
155 | | -$ artisan |
| 72 | +```php |
| 73 | +->withMiddleware(function (Middleware $middleware) { |
| 74 | + $middleware->alias([ |
| 75 | + 'filament.terminal' => \App\Http\Middleware\FilamentTerminalAuth::class, |
| 76 | + ]); |
| 77 | +}) |
156 | 78 | ``` |
157 | | - |
158 | 79 |
|
159 | | -### Migrate |
160 | | -```bash |
161 | | -$ artisan migrate --seed |
162 | | -``` |
163 | | - |
| 80 | +### 5. Update Terminal Config |
164 | 81 |
|
165 | | -### Artisan Tinker |
166 | | -```bash |
167 | | -$ artisan tinker |
| 82 | +In `config/terminal.php`, set: |
| 83 | + |
| 84 | +```php |
| 85 | +'route' => [ |
| 86 | + 'prefix' => 'terminal', |
| 87 | + 'as' => 'terminal.', |
| 88 | + 'middleware' => ['web', 'filament.terminal'], |
| 89 | +], |
168 | 90 | ``` |
169 | | - |
170 | 91 |
|
171 | | -### MySQL |
172 | | -```bash |
173 | | -$ mysql |
174 | | -mysql> select * from users; |
| 92 | +### 6. For Shared Hosting |
175 | 93 |
|
176 | | -# change connection |
177 | | -mysql> use sqlite; |
178 | | -mysql> select * from users; |
179 | | -``` |
180 | | - |
| 94 | +Upload `composer.phar` to your project root: |
181 | 95 |
|
182 | | -### Find Command |
183 | 96 | ```bash |
184 | | -$ find ./ -name * -maxdepth 1 |
| 97 | +curl -o composer.phar https://getcomposer.org/composer.phar |
185 | 98 | ``` |
186 | | - |
187 | 99 |
|
188 | | -### Find and Delete |
189 | | -```bash |
190 | | -$ find ./storage/logs -name * -maxdepth 1 -delete |
191 | | -``` |
192 | | - |
| 100 | +## Usage |
193 | 101 |
|
194 | | -### Vi |
195 | | -```bash |
196 | | -$ vi server.php |
197 | | -``` |
198 | | - |
| 102 | +- Access terminal at: `/terminal` |
| 103 | +- Must be logged into Filament admin panel first |
| 104 | +- All Composer commands available: `composer install`, `composer update`, etc. |
| 105 | +- Smart Tinker: `tinker User::count()`, `tinker config(app.name)` |
199 | 106 |
|
200 | | - |
| 107 | +## Security |
201 | 108 |
|
202 | | - |
| 109 | +- Requires Filament authentication |
| 110 | +- Add role/permission checks in middleware as needed |
| 111 | +- Safe for shared hosting environments |
203 | 112 |
|
204 | | -### Tail |
205 | | -```bash |
206 | | -$ tail |
207 | | -$ tail --line=1 |
208 | | -$ tail server.php |
209 | | -$ tail server.php --line 5 |
210 | | -``` |
211 | | - |
| 113 | +## Commands Available |
212 | 114 |
|
| 115 | +- **Artisan**: All Laravel artisan commands |
| 116 | +- **Tinker**: Interactive PHP with smart auto-corrections |
| 117 | +- **Composer**: Full Composer functionality |
| 118 | +- **System**: find, tail, cleanup, vi, mysql |
213 | 119 |
|
214 | | -### Cleanup |
215 | | -```bash |
216 | | -$ cleanup |
217 | | -``` |
218 | | - |
| 120 | +## Troubleshooting |
| 121 | + |
| 122 | +If Composer commands fail, ensure `composer.phar` is in your project root or Composer is installed on the server. |
| 123 | + |
| 124 | +## Credits |
| 125 | + |
| 126 | +Enhanced version of [recca0120/laravel-terminal](https://github.com/recca0120/laravel-terminal) with Laravel 11/12 compatibility and additional features. |
0 commit comments