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

use php artisan command through controller

<?php
Route::get('/foo', function () {
    Artisan::queue('email:send', [
        'user' => 1, '--queue' => 'default'
    ]);
    //
});
Comment

PREVIOUS NEXT
Code Example
Php :: How to show total count in tables using php 
Php :: magento 1.9 get all product 
Php :: change verify email template laravel 
Php :: install bcmath php 7.3 ubuntu 
Php :: php session array 
Php :: laravel composer create project 
Php :: woocommerce view order details frontend with shortcode 
Php :: how to know if file is empty in php 
Php :: php get last day of month 
Php :: add action hook 
Php :: resource route controller laravel 8 
Php :: how to get length array in php 
Php :: how to convert enum to string in php 
Php :: laravel valet subdomain 
Php :: laravel store blob image into database 
Php :: sanctum 
Php :: carbon get month from date 
Php :: softdelete laravel 
Php :: laravel request file empty 
Php :: add contact form 7 to page templat e 
Php :: laravel migration mediumint length 
Php :: laravel https middleware 
Php :: theme mod disalow wp 
Php :: codeigniter 4 radio button isset 
Php :: php get locale active 
Php :: wp menu declaration 
Php :: laravel digits between does not working 
Php :: how to close login route in laravel 
Php :: laravel collection sort by date 
Php :: php configuration file location in centos 8 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =