Question

I'm developing a Laravel 4 package that uses Sentry 2. In order for Sentry 2 to be installed I have to run migrations and publish their configurations:

php artisan migrate --package=cartalyst/sentry
php artisan config:publish cartalyst/sentry

I would like to allow users of my package to simply run the migrations and publish configs for my own package without having to run that for Sentry 2, or any other package that I might require.

Is there any way to do this? Should this be done at all, or should I keep asking my users to run the migrations/publish confs for every package?

Thanks

EDIT:
As promissed, I've followed @AntonioCarlosRibeiro proposal and created a new Artisan command:

class SybilInstall extends Command
{
    protected $name = 'sybil:install';
    protected $description = 'Install the sybil package';
    public function fire()
    {
        $this->call(
            'migrate',
            array('--package' => 'cartalyst/sentry')
        );
        $this->call(
            'migrate',
            array('--package' => 'ghunti/sybil')
        );
        $this->call(
            'asset:publish',
            array('ghunti/sybil')
        );
    }
}

Now people onlye need to run php artisan sybil:install and it will take care of everything

Was it helpful?

Solution

Inside your package you can run (Laravel 4.1+):

Artisan::call('migrate', array('option' => '--package', 'argument' => 'cartalyst/sentry'));

Artisan::call('config:publish', array('argument' => 'cartalyst/sentry'));

Docs: http://laravel.com/docs/commands#calling-other-commands

On older versions:

Artisan::call('migrate --package=cartalyst/sentry');

Artisan::call('config:publish cartalyst/sentry'):
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top