migrations-generator icon indicating copy to clipboard operation
migrations-generator copied to clipboard

Lumen

Open nasrulhazim opened this issue 9 years ago • 6 comments

Hi there,

Is it possible to have migrations-generator in Lumen too?

trying to use it in Lumen but failed.

migrations-generator-error

Here my composer.json looks like

composer json

nasrulhazim avatar Jan 20 '16 04:01 nasrulhazim

Would have to investigate. Don't really use Lumen myself. But if you are able to fix it, submit a PR and I'll merge

Xethron avatar Apr 08 '16 13:04 Xethron

php artisan migrate:generate

[Doctrine\DBAL\DBALException] Unknown database type json requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

Didn`t support type json ,my database is mysql version >=5.7 . 20160429104108

lance-dd avatar Apr 29 '16 02:04 lance-dd

This doesn't seem to be related to Lumen though, but rather with Doctrine's support for the new MySQL JSON Types. Best to open a issue on Doctrine's repo.

Xethron avatar Apr 30 '16 19:04 Xethron

Any update on whether we can use this with lumen?

benjamindoe avatar Aug 19 '16 11:08 benjamindoe

I'm sure it would be possible. Seems like there might be one or two changes one might have to make. Let me know if you run into any problems.

Xethron avatar Aug 19 '16 14:08 Xethron

Got it working in a Lumen (5.4.6) (Laravel Components 5.4.*) Application.

Basically, Lumen is missing a few core methods that we are copy-pasting back from Laravel.

// bootstrap/app.php 

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/
class Application extends Laravel\Lumen\Application
{
    /**
     * Get the path to the application configuration files.
     *
     * @param string $path Optionally, a path to append to the config path
     * @return string
     */
    public function configPath($path = '')
    {
        return $this->basePath.DIRECTORY_SEPARATOR.'config'.($path ? DIRECTORY_SEPARATOR.$path : $path);
    }
}

if (!function_exists('config_path')) {
    /**
     * Get the configuration path.
     *
     * @param  string $path
     * @return string
     */
    function config_path($path = '')
    {
        return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
    }
}

if (!function_exists('app_path')) {
    /**
     * Get the path to the application folder.
     *
     * @param  string $path
     * @return string
     */
    function app_path($path = '')
    {
        return app('path') . ($path ? DIRECTORY_SEPARATOR . $path : $path);
    }
}

class_alias('Illuminate\Support\Facades\Config', 'Config');

$app = new Application(
    realpath(__DIR__.'/../')
);

// $app->withFacades();

 $app->withEloquent();

Now running artisan migrate:generate should work as expected in Lumen.

@nasrulhazim @Xethron Hope this helps!

cvng avatar Jun 03 '17 03:06 cvng