I'm trying to use Stripe with my Symfony projet. I have to add a php library.
To do that I use composer. I added to my composer.json:
"stripe/stripe-php": "3.*"
Then I have to add:
require_once('vendor/autoload.php');
To my Default controller, but it seems not to work.
Adding that next the uses of the controller, the error says:
Compile Error: main(): Failed opening required 'vendor/autoload.php' (include_path='.;C:\php\pear')
I think I miss something, but what?
Thanks
Best regards
Related
I have an activity plugin that requires another plugin to work correctly.
I followed the recommendation of requesting this plugin as a dependency in the version.php file like this :
$plugin->dependencies = array('local_aws' => 2017071501 ); //AWS php SDK dependency
The problem is when I install my plugin I receive a Warning :
Warning:
require_once(/var/www/moodle/local/aws/sdk/aws-autoloader.php): failed
to open stream: No such file or directory in
/var/www/moodle/mod/tutorship/lib.php on line 37
Fatal error: require_once(): Failed opening required
'/var/www/moodle/local/aws/sdk/aws-autoloader.php'
(include_path='/var/www/moodle/lib/pear:.:/usr/share/php') in
/var/www/moodle/mod/mymodulep/lib.php on line 37
Line 37 uses this code:
// For AWS API Part
require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php');
So it seems to me during the install of my plugin the require_ once is not being satisfied as the AWS plugin has yet to be installed. Well I followed the recommendation of making it a dependency in version.php but it isn't being installed before the require_ once is checked ?
How can I resolve this conundrum ?
I think you are right in your supposition that "require_ once is not being satisfied as the AWS plugin has yet to be installed". To avoid this kind of problem, you should try to avoid to require files of other plugins/libraries in lines that are actually executed during the plugin installation/upgrading procedures. Is it necessary to use the other plugin during the installation of yours?
I would move the require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php'); to some file that is never run during the actual installation/upgrading (avoid the header of lib.php). For example, I would create a class mod/tutorship/classes/some_class.php (properly "namespaced" with namespace mod_tutorship;), do the require_once there and then just instantiate the class in my lib.php within the function that actually needs it.
I've got an issue where I moved the whole folder into a server WITH the vendor files and everything, and it's not loading the classes anymore, while the localhost/local copy is working ok. What might be the problem?
The error code is unnecessary, but I'm adding it anyway..
Fatal error: Uncaught Error: Class 'Google_Service_Adsense' not found in /home/user/full/path/of/the/file/where/its/located
the files are unchanged, only moved into the server. Composer is not in the server, and it's a managed server so no ability to install and update the package or composer either.
composer.json:
{ "require": { "google/apiclient": "^2.0", "google/apiclient-services": "^0.68.0" } }
filepath where the classfile should reside:
myDirectory\vendor\google\apiclient-services\src\Google\Service\AdSense.php
the link where it actually resides in the github repo:
https://github.com/google/google-api-php-client-services/blob/master/src/Google/Service/AdSense.php
update:
after deleting the whole thing from the server and reimporting I'm getting this error:
Fatal error: require(): Failed opening required '/home/user/full/path/of/the/file/where/its/located/vendor/composer/../guzzlehttp/psr7/src/functions_include.php' (include_path='.:/usr/share/pear') in /home/user/full/path/of/the/file/where/its/located/vendor/composer/autoload_real.php on line 66
second update. After removing the directory with the contents from the server once again, uploading a ziped archive, unzipping it I'm still left with the first fatal error.
After struggling for more than I should have with different types of file upload and unextraction I manually loaded the file where the class was located (even though I shouldn't need to do that in my opinion )
like:
require_once __DIR__ . '/vendor/google/apiclient-services/src/Google/Service/AdSense.php';
and it started working.
I am following a tutorial from here:
https://www.simplifiedcoding.net/php-restful-api-framework-slim-tutorial-1/
The tutor said download slim at:
https://github.com/slimphp/Slim
Everything seems ok now but when I try to load the REST at Mozilla's REST easy app. I was given the error:
Warning: require(.././libs/Slim/Slim.php): failed to open stream: No such file or directory in C:\xampp\htdocs\StudentApp\v1\index.php on line 5
Fatal error: require(): Failed opening required '.././libs/Slim/Slim.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\StudentApp\v1\index.php on line 5
I checked the Slim directory and Slim.php is really missing. Can anyone pls help me. Thanks.
Instead of Slim.php and \Slim\Slim(), just use App.php and \Slim\App() as mentioned in the documentation of Slim.
To Explain Well
Use:
require 'vendor/autoload.php';
Instead of:
require '.././libs/Slim/Slim.php';
And use:
$app = new \Slim\App();
Instead of:
$app = new \Slim\Slim();
I have found a solution. What I did is that I downloaded the Slim-2x version from here:
https://github.com/codeguy/Slim
I copied the Slim.php of the Slim-2x to the Slim-3x. It worked but I think there are better solution for this.
Ran into a strange problem - after submitting a form via POST with enctype="multipart/form-data", Doctrine crashes with Fatal Error:
Fatal error: require(): Failed opening required '[PATH/TO/DOCTRINE]/Doctrine\Symfony\Component\HttpFoundation\File\UploadedFile.php' (include_path='.;H:\SERVER\php\PEAR') in [PATH/TO/DOCTRINE]\Doctrine\Common\ClassLoader.class.php on line 164
I don't use Symfony, but I use the Symfony HTTPFoundation and Doctrine separately. And it seems that the error happens when the code calls:
\Symfony\Component\HttpFoundation\Request::createFromGlobals();
I don't understand what does Doctrine have to do with this line...
UPD.
It wasn't autoloading the contents of Symfony HTTPFoundation "File" folder from HTTP Component, so once that was fixed it started working.
But why it was trying to access it via Doctrine Symfony component is still a mystery to me.
While working with PHPExcel in my application I got following errors
In PHPExcel/Autoloader.php file for line “PHPExcel_Shared_ZipStreamWrapper::register();”,
Fatal error: require() [function.require]: Failed opening required '/wamp/www/xxxx/site//common/class/PHPExcel_Shared_ZipStreamWrapper.class.php' (include_path='C:\wamp\www\xxxx\site\common\html_purifier;.;C:\php\pear') in C:\wamp\www\xxxx\site\config\bootstrap.php on line 27
and for line “PHPExcel_Shared_String::buildCharacterSets();”
Fatal error: require() [function.require]: Failed opening required '/wamp/www/xxxx/site//common/class/PHPExcel_Shared_String.class.php' (include_path='C:\wamp\www\xxxx\site\common\html_purifier;.;C:\php\pear') in C:\wamp\www\xxxx\site\config\bootstrap.php on line 27
I'm using wamp with php 5.3.5. and zip xml and gd2 extensions are enable on my local machine.
Please help me for this.
Thanks.
The reference to C:\wamp\www\xxxx\site\config\bootstrap.php suggests you're working with some kind of framework: does it have an autoloader that could be conflicting with or overriding PHPExcel's autoloader?
The reference to
'/wamp/www/xxxx/site//common/class/PHPExcel_Shared_ZipStreamWrapper.class.php'
seems to confirm this.
as something is changing the filename to include ".class" as part of the filename, and it's ignoring PHPExcel's own autoloader that splits a class name to match its directory structure
If you're using a standard framework such as ZF or Symfony, then you should register PHPExcel with that framework. If it's a homebrew, make sure your autoloader is SPL registered
You seem to be having double slashes in your path:
/wamp/www/xxxx/site*//*common
So it's probably a path issue and the autoloader isn't able to load the file because the path is wrong.