├── tests └── .gitkeep ├── assets ├── webartisan.css ├── app.js ├── jquery.terminal.css └── jquery.terminal-0.8.8.min.js ├── .gitignore ├── screenshot.png ├── routes.php ├── composer.json ├── src ├── WebartisanServiceProvider.php ├── views │ └── index.blade.php └── WebartisanController.php └── README.md /tests/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/webartisan.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: black; 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | .DS_Store 4 | Thumbs.db 5 | .idea -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emir/laravel-webartisan/HEAD/screenshot.png -------------------------------------------------------------------------------- /routes.php: -------------------------------------------------------------------------------- 1 | 'webartisan', 'uses' => 'Emir\Webartisan\WebartisanController@index']); 4 | post('artisan/run', ['as' => 'webartisan.run', 'uses' => 'Emir\Webartisan\WebartisanController@actionRpc']); 5 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "emir/laravel-webartisan", 3 | "description": "Web artisan allows to run artisan console commands using a browser", 4 | "keywords": ["webartisan", "artisan", "laravel", "php"], 5 | "homepage": "https://github.com/emir/laravel-webartisan", 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Emir Karşıyakalı", 10 | "email": "emirkarsiyakali@gmail.com" 11 | } 12 | ], 13 | "require": { 14 | "php": ">=5.4.0", 15 | "illuminate/support": "~5.0" 16 | }, 17 | "autoload": { 18 | "psr-4": { 19 | "Emir\\Webartisan\\": "src/" 20 | } 21 | }, 22 | "minimum-stability": "dev" 23 | } -------------------------------------------------------------------------------- /src/WebartisanServiceProvider.php: -------------------------------------------------------------------------------- 1 | publishes([ 15 | __DIR__.'/../assets' => public_path('emir/webartisan'), 16 | ], 'public'); 17 | 18 | $this->loadViewsFrom(__DIR__.'/views', 'webartisan'); 19 | 20 | if (! $this->app->routesAreCached()) { 21 | require __DIR__.'/../routes.php'; 22 | } 23 | } 24 | 25 | /** 26 | * Register the application services. 27 | */ 28 | public function register() 29 | { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/views/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |
7 |
8 | Installation
9 | ------------
10 |
11 | Require this package with composer:
12 |
13 | ```
14 | composer require emir/laravel-webartisan
15 | ```
16 |
17 | After updating composer, because of the security reasons you need to check environment is local.
18 | So you can add the ServiceProvider to app/Providers/AppServiceProvider.php like this:
19 |
20 | ```php
21 | public function register()
22 | {
23 | if ($this->app->environment() == 'local') {
24 | $this->app->register('Emir\Webartisan\WebartisanServiceProvider');
25 | }
26 | }
27 | ```
28 |
29 | Copy the package assets to your local with the publish command:
30 |
31 | ```php
32 | php artisan vendor:publish --provider="Emir\Webartisan\WebartisanServiceProvider"
33 | ```
34 |
35 | Usage
36 | ------------
37 |
38 | After installation you will be able to access web artisan in your browser using
39 | the URL:
40 |
41 | `http://localhost/path/to/artisan`
42 |
43 | License
44 | -------------
45 |
46 | [MIT License](http://emir.mit-license.org/)
--------------------------------------------------------------------------------
/assets/app.js:
--------------------------------------------------------------------------------
1 | jQuery(function($) {
2 | $('#webartisan').terminal(
3 | function(command, term) {
4 | if (command.indexOf('artisan') === 0 || command.indexOf('artisan') === 7) {
5 | $.jrpc(WebArtisanEndpoint, 'artisan', [command.replace(/^artisan ?/, '')], function(json) {
6 | term.echo(json.result);
7 | });
8 | } else if (command === 'help') {
9 | term.echo('Available commands are:');
10 | term.echo('');
11 | term.echo("clear\tClear console");
12 | term.echo('help\tThis help text');
13 | term.echo('artisan\tartisan command');
14 | term.echo('quit\tQuit web artisan');
15 | } else if (command === 'quit') {
16 | if (exitUrl) {
17 | term.echo('Bye!');
18 | location.replace(exitUrl);
19 | } else {
20 | term.echo('There is no exit.');
21 | }
22 | } else {
23 | term.echo('Unknown command.');
24 | }
25 | },
26 | {
27 | greetings: greetings,
28 | name: 'laravel-webartisan',
29 | prompt: '$ '
30 | }
31 | );
32 | $('html').on('keydown', function(){
33 | $('#webartisan').click();
34 | });
35 | });
--------------------------------------------------------------------------------
/src/WebartisanController.php:
--------------------------------------------------------------------------------
1 | getContent());
28 |
29 | switch ($options->method) {
30 | case 'artisan':
31 | list($status, $output) = $this->runCommand(implode(' ', $options->params));
32 |
33 | return ['result' => $output];
34 | }
35 | }
36 |
37 | /**
38 | * Runs console command.
39 | *
40 | * @param string $command
41 | *
42 | * @return array [status, output]
43 | */
44 | private function runCommand($command)
45 | {
46 | $cmd = base_path("artisan $command 2>&1");
47 |
48 | $handler = popen($cmd, 'r');
49 | $output = '';
50 | while (!feof($handler)) {
51 | $output .= fgets($handler);
52 | }
53 | $output = trim($output);
54 | $status = pclose($handler);
55 |
56 | return [$status, $output];
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/assets/jquery.terminal.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This css file is part of jquery terminal
3 | *
4 | * Licensed under GNU LGPL Version 3 license
5 | * Copyright (c) 2011-2013 Jakub Jankiewicz