SCIF / propel-laravel

Propel 2 integration for Laravel framework
MIT License
4 stars 1 forks source link

Config error #6

Open SvanThuijl opened 9 years ago

SvanThuijl commented 9 years ago

Hey Guys,

I have bene trying to figure this out by myself but I can't.

In my local development environment I have this plugin working perfectly but when deploying there is an issue. I get these errors. [Wed Aug 12 18:44:37.429070 2015] [:error] [pid 30427] [client 190.88.209.114:13186] PHP Warning: array_filter() expects parameter 1 to be array, null given in /home/project/laravel/config/propel.php on line 83, referer: http://www.project.com/ [Wed Aug 12 18:44:37.429163 2015] [:error] [pid 30427] [client 190.88.209.114:13186] PHP Warning: array_map(): Argument #2 should be an array in /home/project/laravel/config/propel.php on line 84, referer: http://www.project.com/

I thinks the issue comes from the order laravel has in loading the config files. By adding the line below to the config files I found out that propel.php is loaded before database.php in the production environment. Locally this is the other way around.

echo 'Loaded: ' . microtime(true) . ': ' . FILE . '
';

Result on production: Loaded: 1439398148.1305: /home/project/laravel/config/propel.php Loaded: 1439398148.1313: /home/project/laravel/config/database.php

Result local: Loaded: 1439398248.01: /Users/SvanThuijl/PhpstormProjects/laravel/config/database.php Loaded: 1439398248.02: /Users/SvanThuijl/PhpstormProjects/laravel/config/propel.php

Does anybody know how to solve this issue?

SCIF commented 9 years ago

@SvanThuijl , hi!

Do you use .env in production? What version of framework do you use? The most seems like you collided https://github.com/laravel/framework/issues/6096 issue or something similar.

SvanThuijl commented 9 years ago

My framework version is 5.1.10 and I do use .env to configure everything.

I have "solved" this issue by renaming the file to "propel..php" for now.

Big-Shark commented 9 years ago

Do you use artisan config:cache? If yes, please run php artisan config:cache again.

SvanThuijl commented 9 years ago

I did not do anything to the cache configuration so I don't think so.

When I try this I already get the errors because the propel config fails. Renaming the file and execute this command does not solve the issue.

SCIF commented 9 years ago

@SvanThuijl , you can use php artisan propel:config:convert and it must solve your issue. But it must be rerun on each database config update. I can't reproduce that bug so i can only suggest workarounds :( Provide please trace of debug_print_backtrace() placed in propel.php config to help reproduce or understand root of that bug.

SvanThuijl commented 9 years ago

-bash-4.1$ php artisan propel:config:convert PHP Warning: array_filter() expects parameter 1 to be array, null given in /home/dognailtri/laravel/config/propel.php on line 75 PHP Warning: array_map(): Argument #2 should be an array in /home/dognailtri/laravel/config/propel.php on line 76

[ErrorException]
Undefined index: adapter

-bash-4.1$

SCIF commented 9 years ago

@SvanThuijl , hmm, i digged config loading bootstrapper and seems like it's rarely your system behavior. You can use workaround. Add in your config/propel.php before all return:

if (app()->make('config')->has('database')) {

and next text to the end of file:

} else {
    return [];
}
SCIF commented 9 years ago

Hmm. It will not solve issue (it will replace error happening, but it will be still broken). We need to reread config in ServiceProvider somehow.... @SvanThuijl , let me one more day to think.

SCIF commented 9 years ago

@SvanThuijl , i tried to fix it by a little hack. Try dev version please. You can follow migration guide

SvanThuijl commented 9 years ago

Thanks for the effort.

Your migration manual is not correct. The dev-master has no PropelIntegrationServiceProvider but I configured the GeneratorServiceProvider and RuntimeServiceProvider. This doe snot solve the issue.

SCIF commented 9 years ago

@SvanThuijl , did you changed composer.json repo for package and did you composer update (i forget to add that command)?

SvanThuijl commented 9 years ago

Yes I did. https://github.com/propelorm/PropelLaravel/tree/master/src No PropelIntegrationServiceProvider there. It's only in dev.

I also just noticed the command line tool is not fixed with renaming the file. The config is not loaded at all when I try to run php artisan propel:migration:diff The output for that is below.

  [RuntimeException]                
  Unable to write the "" directory  

  [Symfony\Component\Filesystem\Exception\IOException]  
  Failed to create ""
SCIF commented 9 years ago

@SvanThuijl , hm, i thought that composer dev-master must pull latest HEAD. May be it's incorrect.

Try to explicitly point commit:

"propel/propel-laravel": "dev-master#68a1d0edc784a89fe8853672425cd6198dd83aa1"

and update.

SvanThuijl commented 9 years ago

Composer doesn't update anything at all after changing this.

SCIF commented 9 years ago

@SvanThuijl , can you provide config/propel.php (without passwords, hosts or any other sensitive data) and archived vendor/propel/propel-laravel dir? I simulated your case and my changes fixed it.

SCIF commented 9 years ago

@SvanThuijl , i hope that i totally fixed your issue. Can you install latest propel/propel-laravel composer package at dev-master?

SvanThuijl commented 9 years ago

Got a machine crash and couldn't/didn't work for a while. I'll get back to this asap.

SvanThuijl commented 9 years ago

Problem still persists. Do you have a private contact option? I'll give you access to my install so you can test on my production server.

SCIF commented 9 years ago

@SvanThuijl , feel free to write emails to scif-1986 [at] ya.ru or use skype: scif-1986

xdom commented 9 years ago

Had the same issue and the fix works perfectly, thus by using

"propel/propel-laravel": "dev-develop"

in my composer.json as the fixes are in develop branch.