-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Autoloader (i.e. failed requires) - Read before file a bug report for failed requires! #49
Comments
Is the composer supposed to create the Autoload.php file in Common directory during installation ? |
I got an error, i don't find autoload.php anywhere Link is http://pagerank.co.in/seostats/example/get-alexa-graphs.php Warning: require_once(/home3/shopkera/public_html/www.pagerank.co.in/seostats/example/../vendor/autoload.php) [function.require-once]: failed to open stream: No such file or directory in /home3/shopkera/public_html/www.pagerank.co.in/seostats/example/get-alexa-graphs.php on line 13 Fatal error: require_once() [function.require]: Failed opening required '/home3/shopkera/public_html/www.pagerank.co.in/seostats/example/../vendor/autoload.php' (include_path='.:/opt/php53/lib/php') in /home3/shopkera/public_html/www.pagerank.co.in/seostats/example/get-alexa-graphs.php on line 13 |
Is the composer supposed to create the Autoload.php file in Common directory during installation ? Nope, it's not. Composer creates an autoload.php in Just include composer's autoloader and you're ready to go. Checkout the following: As you can see, the example files are still working almost out of the box when placed in composer's SEOstats install path. There was just a wrong require path to composer's
I'll push a change to fix the wrong paths in a few minutes. |
I got an error, i don't find autoload.php anywhereFailed opening required '/home3/shopkera/public_html/www.pagerank.co.in/seostats/example/../vendor/autoload.php' Well, looking at the paths, you did obviously not installed SEOstats via composer, correct? But http://pagerank.co.in/seostats/composer.json shows that you use the current master branch code (version 2.5.2). Quote from the first post in this thread: "The alternative way, downloading the Zip-File from Github does not work!" I'm sorry if I wasn't clear enough, but you must install SEOstats via composer right now. Or, use the Dev-Version of 2.5.3 here: https://github.com/eyecatchup/SEOstats/archive/dev-253.zip |
Fix commited. Also added some more info to the example files for those who download the master zip. |
Can someone please explain in a bit more detail what this means: "However, you may need to change the forward slashes ("") with the DIRECTORY_SEPARATOR constant." |
Can someone please explain in a bit more detail what this means: "However, you may need to change the forward slashes ("\") with the DIRECTORY_SEPARATOR constant." Well, first of there's a small mistake - it should read backslash.. Anyway, I was trying to say the following: Even though the Zip-File of the Dev-Version of 2.5.3 (https://github.com/eyecatchup/SEOstats/archive/dev-253.zip) contains the custom Autoloader class (which is missing in the current master branch), you still need to change the path separators. The example files (in 2.5.3) contain the following line to specify the path to the bootstrap.php file:
Backslashes work fine on Windows systems, but don't work on *nix. So, unless you work on a Windows machine, you'll need to change these back slashes ("") to forward slashes ("/"):
Or - even better - replace the backslashes with PHP's
|
Made the changes to the examples as per your post. However I get a 500 error. In the error log it gave me the following: [16-Dec-2013 15:29:57 America/New_York] PHP Fatal error: Class 'SEOstats\SEOstats' not found in /home/dpuqsevb/public_html/domain/seo/example/get-alexa-graphs.php on line 21 I changed change this line in Autoloader.php:
to
Then I got the following 500 error: [16-Dec-2013 15:41:10 America/New_York] PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/dpuqsevb/public_html/domain/seo/SEOstats/Common/AutoLoader.php on line 33 I changed all the ' to " in autoloader.php (except for line 18 and 23). PHP Parse error: syntax error, unexpected T_NS_SEPARATOR, expecting ',' or ';' in /home/dpuqsevb/public_html/domain/seo/SEOstats/Common/AutoLoader.php on line 23 It refers to this line:
|
@halbesma thanks for the detailed feedback. checking.. what's your os, server & php version? |
@eyecatchup Also had the same error using another Linux server with PHP 5.4.22 |
With the changes I made today, I can now install SEOstats via composer or use the zip download of the master branch again. All I need to do is to place the example files in the install directory and, in case of the zip download method, adjust the include path (as described in the example files). Both methods (composer and direct download) have been tested by and worked fine for me, on the following systems:
@halbesma I can not reproduce your error. Can you please help me and follow these steps:
If that does not work (and you still get the error that you described upthread), please try one more thing:
/*
*---------------------------------------------------------------
* Register custom PSR-0 Autoloader
*---------------------------------------------------------------
*/
#require_once realpath(__DIR__ . '/Common/AutoLoader.php');
require_once realpath(__DIR__ . '/Common/SplClassLoader.php');
#$autoloader = new \SEOstats\Common\AutoLoader(__NAMESPACE__, dirname(__DIR__));
$autoloader = new \SEOstats\Common\SplClassLoader(__NAMESPACE__, dirname(__DIR__));
$autoloader->register(); Got it working? |
@eyecatchup Fatal error: Class 'SEOstats\Services\SEMRush' not found in /home/domainqu/public_html/SEOstats/get-semrush-graphs.php on line 28 and Fatal error: Class 'SEOstats\Services\SEMRush' not found in /home/domainqu/public_html/SEOstats/get-semrush-metrics.php on line 28 Other than that, all is working perfectly! |
@halbesma Thanks again. Glad to hear it's working for you now. Yep, that's why I asked for |
I'm also facing this issue: Fatal error: Class 'SEOstats\Services\SEMRush' not found in ... When I'm trying to use @eyecatchup SplClassLoader.php Warning: require(../SEOstats/Services/SEMRush.php): failed to open stream: No such file or directory in ... So the quick solution is rename SemRush.php to SEMRush.php, I got it work! see http://domainstatistic.info?q=example.com Rifki |
the bootstrap is not necessary if you just register a reasonable autoloader for modules in your application, something like this: function __autoload_namespaced_module($class) {
$path = str_replace('\\', '/', $class);
if (file_exists($file = (PATH_TO_MODULES_DIR . $path . '.php'))) {
require_once($file);
}
}
spl_autoload_register();
spl_autoload_register('__autoload_namespaced_module'); |
He guy It looks for me that this is a problem with the different write of "SemRush.php" and "SEMRush" On Windows everything ok and Linux don't work this different version. The reason the windows filesystem interpret the UpCase as DownCase, too. For linux are "SemRush.php" and "SEMRush.php" tow different files... Solution 1: rename the file name |
We fix this with the commit right? so this can close? |
I will close this issue now. If any one can reproduce this with the current beta (2.5.3-beta4) we can open this again |
LAST EDITED 2013-12-16
Okay. First, there were some cross-platform path name seperator issues ("" instead of "/"), which resulted in many users experienced failed requires. On the other hand, there were some composer users having issues with my custom PSR-0 Autoloader class.
Because these issues existed for some time and I still had no time to fix it myself, I merged #41 and #42. These commits (thanks to @francisbesset) fix both issues by using the PHP constant
DIRECTORY_SEPARATOR
as a path name seperator and replacing the custom Autoloader class by composer's.However, this breaks autoloading without composer for the current master branch. I will merge back the custom PSR-0 Autoloader class for alternative use with the upcoming 2.5.3 release.
If you have issues with failed requires, for the moment the best way is to use composer to install SEOstats (as referenced here). The alternative way, downloading the Zip-File from Github does not work! If there's no way for you to work with composer, you can still download the Zip-File of the Dev-Version of 2.5.3 here: https://github.com/eyecatchup/SEOstats/archive/dev-253.zip . This still includes the "old" custom Autoloader class for you to use the examples out of the box. However, you need to change the back slashes ("") - used in the example files to require the autoloader class - with the
DIRECTORY_SEPARATOR
constant (see this comment for more detailed instructions).The text was updated successfully, but these errors were encountered: