Search
 
SCRIPT & CODE EXAMPLE
 

PHP

run artisan command from controller

If you have simple job to do you can do it from route file. 
For example you want to clear cache. In terminal it would be php artisan 
cache:clear In route file that would be:

Artisan::call('cache:clear');
Comment

run artisan command from controller

// call artisan command
Artisan::call("syncdb:sales-item");
Comment

run artisan commands in laravel controllers

/*
|=======================================================
| Run Artisan commands in laravel controllers
|=======================================================
*/
public function home()
{
     
  Artisan::call('cache:clear');
  echo "Cache Cleared <br>";

  Artisan::call('config:cache');
  echo "config cache are cleared <br>";

  Artisan::call('route:cache');
  echo "routes cache are cleared <br>";

  Artisan::call('optimize:clear');
  echo "optimized cleared <br>";

  Artisan::call('storage:link');
  echo "storage linked <br>";
}
Comment

laravel run controller from command line

 <?php

namespace AppConsoleCommands;

use IlluminateConsoleCommand;
use AppHttpControllersHelloWorldController;

class MakeImportsCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'helloworld';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Say Hello World Controller';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        return $this -> helloWorld();

    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: php polymorphism 
Php :: just page name in url 
Php :: php associative array 
Php :: php get screen width 
Php :: create custom rule in laravel 
Php :: how to push associative array in php 
Php :: wordpress programmatically change slug of media attachment site:wordpress.stackexchange.com 
Php :: Target class [AppHttpControllersAdminUserController] does not exist. larvel 8 
Php :: php catch mysqli_connect(): (HY000/1045): Access denied 
Php :: remove exact characters from string using php 
Php :: get action name in yii2 
Php :: logout all the users from site wordpress 
Php :: php code to submit a radio button value using onclick function 
Php :: use php-fpm with apache 
Php :: install latest php on feren os 
Java :: set size of a jframe 
Java :: java get current year 
Java :: java print stack trace to string 
Java :: create a random char java 
Java :: open link in android studio 
Java :: how to format a datetime object to show date and time and milliseconds in java 
Java :: processing string to int 
Java :: cast long to string java 
Java :: java cast duration to long 
Java :: capcitor FERR_CLEARTEXT_NOT_PERMITTED 
Java :: stream distinct by property 
Java :: spring boot resource optional request param 
Java :: Access denied finding property "camera.aux.packagelist" 
Java :: java how to get elapsedTime 
Java :: format localdate java 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =