How to use php commands, compiler, artisan ... (Laravel) manually

I have one problem: I do not have access to the ssh server, so I can not use php artisan, composer and other commands.
As I can, they do nothing but modify files or just copy php src files to specific directories.
To understand this process better, and due to the lack of ssh access to the server, I am looking for a maintenance job, manual or article on how I can execute these commands manually.
For example, I need to execute

php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider"

What should I do in this case, it would be nice to find some document that describes what to do manually to get the same result.

+4
source share
2 answers

Laravel provides a convenient facade for the teams of craftsmen.

Just use Artisan::call('your-command')where you need it.

Example:

Route::get('artisan-command/{command}', function($command) {
    Artisan::call($command);
});

Your url is as follows: http://yourhost.com/artisan-command/db:seed

More specific for your use case:

Route::get('vendor-publish/{provider}', function($provider) {
    Artisan::call('vendor:publish', ['provider' => $provider]);
});

And URL: http://yourhost.com/vendor-publish/Tymon\JWTAuth\Providers\JWTAuthServiceProvider

Link: Artisan Console in Laravel Docs

+1
source

You can execute commands from your application. You can do something like this:

Route::get('execute/my/command', function(){
    exec("php path/to/your/project/artisan your-command",$resultLines);
    Foreach($resultLines as $resultLine){
         echo $resultLine;
     }
});

The first property of exec is your command, and the second variable is to save the result. I hope that helps you

0
source

Source: https://habr.com/ru/post/1610054/


All Articles