shpasser / GaeSupportL5

Google App Engine Support package for Laravel 5
MIT License
160 stars 27 forks source link

Function parse_ini_file does not compatible with the new APP_KEY format #53

Closed tinpont closed 8 years ago

tinpont commented 8 years ago

I'm using GaeSupportL5@dev-master.

Laravel php artisan key:generate source code: https://github.com/laravel/framework/commit/370ae34d41362c3adb61bc5304068fb68e626586

    /**
     * Generate a random key for the application.
     *
     * @return string
     */
    protected function generateRandomKey()
    {
        return 'base64:'.base64_encode(random_bytes(
            $this->laravel['config']['app.cipher'] == 'AES-128-CBC' ? 16 : 32
        ));
    }

This will generate string like:

base64:DuyGT1doEMYlY/DQ87GedVqH4THPc75U3CSJLCkl6PI=

Which is not compatible with function parse_ini_file, error message:

[2016-07-02 21:03:33] local.ERROR: exception 'ErrorException' with message 'parse error in project/app/../.env on line 3' in project/vendor/shpasser/gae-support-l5/src/Shpasser/GaeSupportL5/Setup/IniHelper.php:28
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'parse error in ...', 'project/.env', 28, Array)
#1 project/vendor/shpasser/gae-support-l5/src/Shpasser/GaeSupportL5/Setup/IniHelper.php(28): parse_ini_file('project/.env')
#2 project/vendor/shpasser/gae-support-l5/src/Shpasser/GaeSupportL5/Setup/Configurator.php(115): Shpasser\GaeSupportL5\Setup\IniHelper->read('project/.env')
#3 project/vendor/shpasser/gae-support-l5/src/Shpasser/GaeSupportL5/Setup/Configurator.php(56): Shpasser\GaeSupportL5\Setup\Configurator->createEnvProductionFile('project/.env', 'project/.env', NULL, NULL)
#4 project/vendor/shpasser/gae-support-l5/src/Shpasser/GaeSupportL5/Setup/SetupCommand.php(58): Shpasser\GaeSupportL5\Setup\Configurator->configure('gae-app', true, true, NULL, NULL, NULL, NULL)
#5 [internal function]: Shpasser\GaeSupportL5\Setup\SetupCommand->fire()
#6 project/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#7 project/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#8 project/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 project/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 project/vendor/symfony/console/Application.php(791): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 project/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Shpasser\GaeSupportL5\Setup\SetupCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 project/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 project/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 {main}  

.env file:

APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:DuyGT1doEMYlY/DQ87GedVqH4THPc75U3CSJLCkl6PI=
APP_URL=http://localhost

Simple solution: remove last = character.

shpasser commented 8 years ago

Exactly for that reason I replaced IniHelper with EnvHelper class. Please make sure you're using the right branch, the latest version of Configurator.php does not have IniHelper on line 115.

tinpont commented 8 years ago

I'm sorry about wasting your time. Maybe this issue cause by GoogleAppEngineLauncher file cache. After I reinstall package, everything works fine.