title: Programmatically executing Artisan CLI commands failing in Laravel
body: <p>I'm trying to execute Artisan CLI command in a Laravel controller using programming conditional logic(if/else). In other words, I'm trying to execute Artisan CLI command through using HTTP request/response cycle. However, when I'm using a form submission to do this I get this error:</p>
  
  <pre><code>Spatie\DbDumper\Exceptions\DumpFailed thrown with message "The dump 
  process failed with exitcode 2 : Misuse of shell builtins : sh: 1: 
  cannot create 
  /var/www/html/DC_for_Rony/dc/storage/app/Laravel/dump.sql: 
  Permission denied 
  "
  </code></pre>
  
  <p>I've already researched everything online about this issue. Unfortunately none of them satisfied with the correct solution that I need.</p>
  
  <p>DBBackupController.php(for Programming Logic, I'm only stating the function):</p>
  
  <pre><code>    public function auth_bkp(Request $request){
          if (Auth::user()) {
            if (Auth::user()-&gt;role == 3 &amp;&amp; $request-&gt;pass == 
              'dc_for_rony') {
                // dd('1');
                Artisan::call(BackupDatabase::class,array());
                return back()-&gt;with('yesss!!');
            }else{
                //dd('2');
              return back()-&gt;with('sorry!');
            }
          }else{
  
          }
     }
  </code></pre>
  
  <p>config/database.php(for Configuration Issues Just the mysql driver):</p>
  
  <pre><code>   'mysql' =&gt; [
          'driver' =&gt; 'mysql',
          'host' =&gt; env('DB_HOST', 'localhost'),
          'port' =&gt; env('DB_PORT', '3306'),
          'database' =&gt; env('DB_DATABASE', ''),
          'username' =&gt; env('DB_USERNAME', ''),
          'password' =&gt; env('DB_PASSWORD', ''),
          'unix_socket' =&gt; env('DB_SOCKET', ''),
          'charset' =&gt; 'utf8mb4',
          'collation' =&gt; 'utf8mb4_unicode_ci',
          'prefix' =&gt; '',
          'strict' =&gt; true,
          'engine' =&gt; null,
          'dump' =&gt; [
             'dump_binary_path' =&gt; '/usr/bin', // only the path, so 
              without `mysqldump` or `pg_dump`
             'use_single_transaction',
             'timeout' =&gt; 60 * 5, // 5 minute timeout
             'exclude_tables' =&gt; ['table1', 'table2'],
             'add_extra_option' =&gt; '--optionname=optionvalue', 
          ]
      ],
  </code></pre>
  
  <p>I'm expecting to generate the Artisan CLI command if the logic suffices. My mysqldump is already installed.Can anybody help?</p>