Skip to content

Instantly share code, notes, and snippets.

@aaronkaz
Created January 30, 2019 22:21
Show Gist options
  • Save aaronkaz/44586f270410d011dc3d93f960c046e7 to your computer and use it in GitHub Desktop.
Save aaronkaz/44586f270410d011dc3d93f960c046e7 to your computer and use it in GitHub Desktop.
Monkey-path fix for Call to undefined method Laravel\Lumen\Application::configPath()
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
$this->app->register(GeneratorsServiceProvider::class);
$this->app->register(MigrationsGeneratorServiceProvider::class);
}
}
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Way\Generators\GeneratorsServiceProvider as BaseProvider;
class GeneratorsServiceProvider extends BaseProvider
{
/**
* Register the config paths
*/
public function registerConfig()
{
$userConfigFile = config_path().'/generators.config.php';
$packageConfigFile = base_path().'/vendor/xethron/laravel-4-generators/src/config/config.php';
$config = $this->app['files']->getRequire($packageConfigFile);
if (file_exists($userConfigFile)) {
$userConfig = $this->app['files']->getRequire($userConfigFile);
$config = array_replace_recursive($config, $userConfig);
}
$this->app['config']->set('generators.config', $config);
}
}
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Xethron\MigrationsGenerator\MigrateGenerateCommand as BaseCommand;
class MigrateGenerateCommand extends BaseCommand
{
/**
* Get a directory path through a command option, or from the configuration.
*
* @param $option
* @param $configName
* @return string
*/
protected function getPathByOptionOrConfig($option, $configName)
{
if ($path = $this->option($option)) return $path;
return config()->get("generators.config.{$configName}");
}
}
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider as BaseProvider;
class MigrationsGeneratorServiceProvider extends BaseProvider
{
public function register()
{
$this->app->singleton('migration.generate',
function($app) {
return new MigrateGenerateCommand(
$app->make('Way\Generators\Generator'),
$app->make('Way\Generators\Filesystem\Filesystem'),
$app->make('Way\Generators\Compilers\TemplateCompiler'),
$app->make('migration.repository'),
$app->make('config')
);
});
$this->commands('migration.generate');
// Bind the Repository Interface to $app['migrations.repository']
$this->app->bind('Illuminate\Database\Migrations\MigrationRepositoryInterface', function($app) {
return $app['migration.repository'];
});
}
}
@aaronkaz
Copy link
Author

@faizalmansor
Copy link

Is the file MigrateGenerateCommand.php should be placed in app\Providers folder too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment