Closed outrunthewolf closed 9 years ago
I am having similar redeclaration problem with nginx. Commenting out the require (require(LIB_DIR .'pico.php');) from index.php fixes the problem.
I dont think this has anything to do with nginx. I came across the same problem using apache.
A weird one :monkey_face:
I just faced the same problem after installing a plugin via composer. Composer generates file vendor/composer/autoload_files.php
with the following content:
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
$baseDir . '/lib/pico.php',
);
This conflicts with loading pico.php in index.php
. I'm not sure what should be the best approach. For now commenting either line works. Any suggestions from the PHP experts?
Commenting one of them out is definitely the right approach. I would opt for the one in index.php.
Composer is actually configured to insert that statement which makes sense. If however you wanted to remove it from composer you'd have to go to composer.json and uncomment the following lines:
"autoload": {
"files": ["lib/pico.php"]
}
Then when you run the install it should not generate the statement any more. But again I'd say the composer way is a bit more elegant.
would changing the line:
require(LIB_DIR .'pico.php');
to
require_once(LIB_DIR .'pico.php');
fix the issue?
Same issue here. Changing to require_once cleared it up for me.
Made a p/r to update the index file, should patch it for now.
Thanks @outrunthewolf. Can @picocms please accept his pull request?
This works great for me. Thanks. Would be great to see it pushed by @picocms
Done, sorry about the delay.
@picocms Thanks, mate!
@picocms Cheers dude
Hi there.
Using nginx, I get:
"Fatal error: Cannot redeclare class Pico in /home/pico/public_html/lib/pico.php on line 13"
Fixed this by commenting the require in index.php.
Do you not need the require because you're autoloading? Or is this something to do with nginx/php?