Support the ongoing development of Laravel.io →
Configuration Packages

I developed a laravel 4 package that backs up mysql database and pushed to github and packagist. When I pull the package on another laravel installation, all works fine. I publish the config file of the package with no problems, however when I try override some of the configuration in the published config file, the package still uses the original config file in the vendor, it does not look at the published config file. Here is my code:

Vendor/rafia/db-backup/src/Rafia/DbBackup/backupdatabase.php

<?php

namespace Rafia\DbBackup;
use Config;
use Illuminate\Filesystem\Filesystem;
class BackupDatabase {
/**
* @var
*/
private $filesystem;
/**
   * @param Filesystem $filesystem
   */
   public function __construct(Filesystem $filesystem)
  {
      $this->filesystem = $filesystem;
  }
    public function backup()
    {
    $this->DbBackupFolder();
    if($this->runBackup() == 0)
    {
        return true;
    }
    return false;
   }
   private function DbBackupFolder()
   {
    if(!$this->filesystem->isDirectory(Config::get('DbBackup::DbBackupPath')))
    {
       return $this->filesystem->makeDirectory(Config::get('DbBackup::DbBackupPath'));
    }
    return true;
   }
    private function runBackup()
   {
    $output = array();
    $return_var = NULL;
        $command = Config::get('DbBackup::DbMysqlDumpPath')." --opt --host=".Config::get('DbBackup::DbHost')." --        user=".Config::get('DbBackup::DbUser')." --password=".Config::get('DbBackup::DbPass')."      ".Config::get('DbBackup::DbName')." >     ".Config::get('DbBackup::DbBackupPath')."/".Config::get('DbBackup::DbName')."_".date('m_d_y_g-i-a').".sql";
    $run = exec($command, $output, $return_var);
    return $return_var;
  }
  }

Vendor/rafia/db-backup/src/Rafia/DbBackup/DbBackupServiceProvider.php

   <?php namespace Rafia\DbBackup;

   use Illuminate\Foundation\AliasLoader;
   use Illuminate\Support\ServiceProvider;


    class DbBackupServiceProvider extends ServiceProvider {

  /**
  * Indicates if loading of the provider is deferred.
 *
 * @var bool
 */
   protected $defer = false;

  /**
 * Register the service provider.
*
 * @return void
 */
   public function register()
   {
    $this->app['BackupDatabase'] = $this->app->share(function($app)
    {
        $filesystem = $this->app->make('Illuminate\Filesystem\Filesystem');
        return new BackupDatabase($filesystem);
    });
 
    $this->app->booting(function()
   {
       AliasLoader::getInstance()->alias('BackupDatabase', 'Rafia\DbBackup\Facades\BackupDatabaseFacade');
    });
   }

   public function boot()
   {
   $this->package('Rafia/DbBackup');

   }

   /**
     * Get the services provided by the provider.
 *
 * @return array
 */
    public function provides()
   {
    return array();
   }

}

Vendor/rafia/db-backup/src/config/config.php

  <?php

  return [
   'DbName' => 'packages',
   'DbUser' => 'root',
   'DbPass' => '',
  'DbHost' => 'localhost',
  'DbMysqlDumpPath' => 'C:/xampp/mysql/bin/mysqldump',
  'DbBackupPath' => app_path().'/storage/DbBackup'
  ];

Vendor/rafia/db-backup/src/Rafia/DbBackup/Facades/BackupDatabaseFacade.php

   <?php


   namespace Rafia\DbBackup\Facades;

   use Illuminate\Support\Facades\Facade;

   class BackupDatabaseFacade extends Facade {

   protected static function getFacadeAccessor() { return 'BackupDatabase'; }

    }

Thank you in advance for your help

Last updated 3 years ago.
0

You can try using "Cloudbacko home" software for taking backup . as this software gives backup and helps restoring as well i am basically using this software from long time , this software is best use for restoring i.e it gives large space for restoring. Leaving a link just check:

0

Sign in to participate in this thread!

Eventy

Your banner here too?

aracademia aracademia Joined 25 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.