I'm setting up a demo site for a Wordpress plugin on Heroku. My plugin uses composer to manage dependencies, and it's configured as a git submodule on my local installation. I push to heroku and everything seems to work. I use heroku run bash to ssh into the app and manually run composer install from inside my plugin. Then I log into the site and try to activate my plugin... but I get the following error:
Plugin could not be activated because it triggered a fatal error.
Warning: require_once(/app/wp-content/plugins/wp-github-pipeline/vendor/autoload.php): failed to open stream: No such file or directory in /app/wp-content/plugins/wp-github-pipeline/wp-github-pipeline.php on line 23 Fatal error: require_once(): Failed opening required '/app/wp-content/plugins/wp-github-pipeline/vendor/autoload.php' (include_path='.:/app/.heroku/php/lib/php') in /app/wp-content/plugins/wp-github-pipeline/wp-github-pipeline.php on line 23
I don't get it. With heroku run bash I can see that the file is actually there. And I don't get this issue locally or on another remote server. Why is it happening here?
I can't say for sure why this worked but it appears that Heroku doesn't really play nicely with composer.json somewhere other than the project root. So I took my project's composer.json and moved it to the project root, then I added...
"config": {
"vendor-dir": "wp-content/plugins/wp-github-pipeline/vendor"
}
...which caused the dependancies I needed (and the autoload.php) to get installed in the original location.
With this, I am able to push to Heroku normally without issues.
I have NO idea why I was able to run composer install manually without it working. I also have NO idea why heroku run bash would show me files that aren't actually there.
According to me you have to regenerate the autoload. Hope that you have written code within composer.json for autoloads.
composer dump-autoload
This will regenerate your autoload and it will solve your problem. If not please modify your question by pasting your composer.json.
What I did to solve this was add an include_path to my .user.ini file. That ini file needs to be located in the document root, not the app's root.
include_path = ".:/app/.heroku/php/lib/php:/app/vendor/"
Don't copy my include_path example verbatim, as it might now be the needed include path for your app. Get your current include path from Heroku's error log, and then append :/app/vendor to it.
What's important there is adding /app/vendor/ to the include_path. That will point yourrequire php statement to the spot where Heroku puts the autoload.php.
Related
I have successfully uploaded my symfony app to the server. I have also copied the content of the web folder into the public_html folder of my website. But when I access my app via the www.domain.com I get this error
Warning: require_once(/home/domain/public_html/../app/bootstrap.php.cache): failed to open stream: No such file or directory in /home/domain/public_html/app.php on line 6
Fatal error: require_once(): Failed opening required '/home/domain/public_html/../app/bootstrap.php.cache' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/domain/public_html/app.php on line 6
After researching I found that you can run composer install on the server but my challenge is that I dont know how to run cli command on the server via ssh/cpanel.
Please who will be kind enough to show me the way. This is my first attempt on trying to host a symfony application
When you don't run an composer install your dependencies are missing and the bootstrap.cache.php isn't created. So you have to upload the file and the complete vendor folder.
But i would prefer to take a look at your SSH connection and use the correct way. Otherwise you have to upload every time your complete sources including your vendor folder which can take a lot of time.
And the next think is your path. The components from your Symfony application are normally outside of your webroot. So you have to be sure that you can access that folders outside your webroot.
In some systems you have to allow that before you can use it. Otherwise you have to upload your complete application to your public_html folder and put your domain to the web subdirectory.
When I try to start Laravel artisan on a Command-line using php artisan serve, it works because I get the "Laravel development server started on http://localhost:8000/".
However, when I try to run 'localhost:8000' on my web browser, I get this error:
"Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:\xampp\htdocs\laravel\laravel/server.php' (include_path='.;C:\xampp\php\PEAR') in Unknown on line 0"
In your project folder, the server.php file is missing so you got this error
The solution will to create another project then copy the newly created server.php this will solve it.
Another Solution is:
Open the link: https://github.com/laravel/laravel/blob/master/server.php
Copy all code
Open Notepad and paste your copy code
save Notepad file and set name server.php
Copy the server.php file and paste it inside your Laravel project
Run your project again in browser Now you will not get an error and the Laravel project will work properly.
Try changing your port to 8080. Maybe some other app is already in charge of port 8000 aka port in use.
I also face that problem and after quite a time I become to solve it. it very simple to solve it.
When I copy an old project to new Laravel 5.6 setups. I face this problem.
so you should first install new laravel setup.
copy your previously created project. when you will use php artisan serve. you will see this type of error.
So it's mean in your project folder "server.php" file is missing.
copy this file from other project and paste it your project. it will run.
my problem like this which was I facing solve it by this method.
There are 2 ways to remove this.
FIRST WAY:
(1) copy the server.php from your project folder (
c:\xampp\htdocs\laravel\public\server.php)
NOTE: laravel is name of my project
(2) the file "server.php" which you have copied, paste this file to root folder (c:\xampp\htdocs\laravel)
SECOND WAY:
Trying add this file to root project folder https://github.com/laravel/laravel/blob/master/server.php
I had the same issue, but it was because of bad configuration file paths.php in Boostrap folder (Laravel 4.2).
This Line,
'public' => DIR.'/../public',
It seems the project i cloned had setup the the root of the project to be public, So i removed 'public' and become
'public' => DIR.'/..', and everything worked fine. I hope this will help somebody.
So i can conclude that, on top of missing server.php file as how others have been suggesting, also Public folder path misconfiguration in Bootstrap paths.php or app.php for higher Laravel can result into that error.
I am using this wordpress skeleton locally and have an issue getting it to work on AWS Beanstalk. When I open /index.php I am seeing a blank page in the browser and the following message in the logs:
PHP Fatal error: require(): Failed opening required './wp/wp-blog-header.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/app/current/index.php on line 4
The location ./wp/wp-blog-header.php relative to file index.php exists, but php on beanstalk is unable to find it. When I change it to wp/wp-blog-header.php its not working either.
Update
It turns out the command eb deploy is not pushing submodules and my setup is using a submodule. So the files are actually not there because they are in a submodule. Is there a way to make this happen? I am using awsebcli 3.1.2.
You could use .ebextensions config to run any commands. Also for modules install/deploy.
I am trying to upload my project on the distant server, I simply uploaded the files on the distant server, checked the config.php, which says that all is good. I have removed the if conditions for only local access. But when i try to open the app_dev.php or app.php i keep getting this error
ContextErrorException: Warning:
file_get_contents(C:\wamp2\www\Symfony\src\Les\CouvertsBundle/Resources/views/Couverts/index.html.twig)
: failed to open stream: No such file or directory
in /homepages/26/d367595533/htdocs/Symfony/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line 130
i have not found any answers to this question, maybe not looking for it properly. But could anyone explain to me why would this error is occuring? Why is symfony looking for the files with the local address?
I followed this tutorial to deploy project in production http://fr.openclassrooms.com/informatique/cours/developpez-votre-site-web-avec-le-framework-symfony2/deployer-son-site-symfony2-en-production. The steps seem pretty straight forward, but maybe i am missing something.
This is really frustrating, because my project is ready but i can't seem to put it online due to this problem.
The problem seemed to be the command php app/console cache:clear and php app/console cache:clear --env=prod didn't completely clear the cache folder.
It can happen if the user running the command hasn't the permission to delete files/folder in app/cache/ Manually removing the content of this folder can solve the issue (rm -rf app/cache/*).
Just clearing the cache manually at (projectname/app/cache) instead of the command line worked for me (version 2.8).
I am running on a Windows machine. I installed WT-NMP and I am trying to install composer.phar. No matter from what folder I run this
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
it always installs in the /bin/php-5.5.8/ instead of the /www/project folder where I want it. Because of this, whenever I try to run
composer update
I receive an error that it can't find the composer.json file (because the json file is in www/project but it is searching for it in /bin/php-5.5.8 instead). I tried everything that I could think of but I can't get it to work.
Any help is appreciated. Thanks!
You could try to find out the reason why it does what you don't like, but the installer script essentially only checks some settings of the PHP used before downloading the .phar file because debugging things inside the .phar is problematic, i.e. it would be a support nightmare if you'd simply download the pure .phar and try to run it if your PHP is unable to do so.
Long story short: You can simply copy or move the downloaded composer.phar to any location you like, and it will work.
you only need to specify where you want to install composer by changing PHP`s current working directory with chdir:
C:\WT-NMP\bin\php.bat -r "chdir('C:/WT-NMP/WWW'); eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
an odd solution to an odd installation method ;)