PHP Startup: Failed opening index.php after composer install/update - php

I've uploaded my webapp (made with Laravel 5.8). I run composer install via SSH so vendor is created, but when opening website I get:
Warning: PHP Startup: failed to open stream: No such file or directory in /index.php on line 24
Fatal error: PHP Startup: Failed opening required '//../vendor/autoload.php' (include_path='.:/:/usr/local/php72/lib/pear') in /index.php on line 24
When I change server's PHP default version, for example to 7.1, in second line path changes to: usr/local/php71/lib/pear .
On localhost, and on different with the very same vendor everything works fine.
So I assume something is wrong with php's path?
I've already run composer update or dumb-autoload with no success.
E1:
define('LARAVEL_START', microtime(true));
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);

try to run following command in your application
sudo chmod -R 777 bootstrap/cache storage

Related

How should I properly develop laravel app on hosting

I'm trying to develop Laravel project on hosting server, but I have a problem with public_html/index.php
Structure of files is:
/laravel/(all laravel files except /public)
/public_html/(all files from laravel /public folder)
File /public_html/index.php (without comments):
<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
if (file_exists(__DIR__.'/../laravel/storage/framework/maintenance.php')) {
require __DIR__.'/../laravel/storage/framework/maintenance.php';
}
require __DIR__.'/../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
$kernel = $app->make(Kernel::class);
$response = tap($kernel->handle(
$request = Request::capture()
))->send();
$kernel->terminate($request, $response);
And I'm receiving following problem:
Warning: PHP Startup: failed to open stream: No such file or directory in /index.php on line 34
Fatal error: PHP Startup: Failed opening required '//../laravel/vendor/autoload.php' (include_path='.:/:/usr/local/php74/lib/pear') in /index.php on line 34
I'm accessing website by https://my_domain.com.

Laravel Shared Hosting: /www/../vendor/autoload.php: failed to open stream: No such file or directory

I am trying to host a Laravel application on shared hosting. The default folder is '/www' and can't be changed, there is no public_html folder. However when surfing to the website I get an Error 500 and in the logs I get:
Got error 'PHP message: PHP Warning: require(/absolutepath/www/../vendor/autoload.php): failed to open stream: No such file or directory in /absolutepath/www/index.php on line 34PHP message: PHP Fatal error: require(): Failed opening required '/absolutepath/www/../vendor/autoload.php' (include_path='.') in /absolutepath/www/index.php on line 34'
Everything works locally and I have followed a guide on how to setup a Laravel project for Shared Hosting. I did the following:
Move index.php and .htaccess to the root of the project
Changed require __DIR__.'/../vendor/autoload.php'; to require __DIR__.'/vendor/autoload.php'; in index.php
Changed $app = require_once __DIR__.'/../bootstrap/app.php'; to$app = require_once __DIR__.'/bootstrap/app.php'; in index.php
Changed require_once __DIR__.'/public/index.php'; to require_once __DIR__.'/index.php'; in server.php
My file structure looks as follows:
File structure
I have already tried:
composer update & composer dump-autoload
composer install
php artisan key:generate
Also:
php artisan route:cache
php artisan view:clear
php artisan config:cache

What is the Path to root folder? Vimeo API

Im trying to run this Vimeo API in my PHP, and these are the error messages:
Warning: require(D:\XAMPP\htdocs\MyVimeo/autoload.php): failed to open stream: No such file or directory in D:\XAMPP\htdocs\MyVimeo\testing.php on line 9
Fatal error: require(): Failed opening required 'D:\XAMPP\htdocs\MyVimeo/autoload.php' (include_path='D:\XAMPP\php\PEAR') in D:\XAMPP\htdocs\MyVimeo\testing.php on line 9
And my question is, what is the path to the root folder? This is my source code that I'm trying to run:
<?php
require 'D:\XAMPP\htdocs\MyVimeo/autoload.php';
use Vimeo\Vimeo;
$client = new Vimeo("xxx","xxx","xxx");
$url="https://api.vimeo.com/videos/xxx";
$ch=curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
echo curl_exec($ch);
curl_close($ch);
You just need to put require 'vendor/autoload.php'; and not change to actual path.
What you are missing is running composer install command in your root directory from the terminal
According to the documentation
With Composer, in the root directory of your project.
composer require vimeo/vimeo-api
Please note that this library requires at least PHP 7.1 installed. If you are on PHP 5.6, or PHP 7.0, please use install the package with the following:
composer require vimeo/vimeo-api ^2.0
Then once you do that, you can use
require "vendor/autoload.php";

Composer install error - jms-security-extra-bundle

I'm in the process of trying to upgrade a PHP application from Symfony 2.x to 3.x. I've managed to resolve dependency issues for the various packages we're using and all the packages download and install. However when the composer install triggers a cache clear it errors out with the following:
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Warning: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: require_once(/home/vagrant/code/symfony/vendor/jms/security-extr
a-bundle/Tests/Functional/../../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/code/symfony/vendor/jms/secu
rity-extra-bundle/Tests/Functional/AppKernel.php:5
Stack trace:
#0 /home/vagrant/code/symfony/vendor/jms/security-extra-bundle/Tests/Functional/AppKernel.php(5): require_once()
#1 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php(191): require_
once('/home/vagrant/c...')
#2 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php(145): Symfony\
Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler->convertFileToClass('/home/vagrant/c...', '/home/vagrant/c...', 'JMS\\SecurityExt..
.')
#3 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/Fata in /home/vagrant/code/symfony/vendor/jms/security-extra-bundle
/Tests/Functional/AppKernel.php on line 5
Fatal error: Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler::main(): Failed opening required '/home/vagrant/code/symfony/v
endor/jms/security-extra-bundle/Tests/Functional/../../vendor/autoload.php' (include_path='.:/usr/share/php') in /home/vagrant/code/symfony/vendor/j
ms/security-extra-bundle/Tests/Functional/AppKernel.php on line 5
The file it's referring to has these lines at the top:
<?php
namespace JMS\SecurityExtraBundle\Tests\Functional;
require_once __DIR__.'/../../vendor/autoload.php';
There is no autoload.php at that path. I suspect that this file is being autoloaded when it shouldn't be but I'm not sure how to resolve this.
I have compared the contents of the /vendor/jms/security-extra-bundle/Tests/Functional/AppKernel.php file to another Symfony 3 project that we have and it's exactly the same so this leads me to think it's even more likely that this file is being autoloaded when it shouldn't be.
What can I do to resolve this and get past the cache:clear --no-warmup command?
I have now resolved this. I had originally copied bin/console from another Symfony 3 project. It seems however that the correct approach was to move the existing app/console to the bin/console path and update the include paths to correctly reference the bootstrap.php.cache file in ../var/ and the autoload.php and AppKernel.php in ../app. The whole bin/console file now looks like this:
#!/usr/bin/env php
<?php
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
set_time_limit(0);
require_once __DIR__.'/../var/bootstrap.php.cache';
require_once __DIR__.'/../app/autoload.php';
require_once __DIR__.'/../app/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
if ($debug) {
Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);

Cannot require Zend/Config/Ini when Zend is in the include path?

When I try this:
require_once 'Zend/Config/Ini.php';
I am getting this error in my Zend Framework application:
Warning: require_once(Zend/Config/Ini.php) [function.require-once]: failed to open stream: No such file or directory in /path/to/functions.php on line 408
When I print out my include path, it is:
string(101) "/path/to/www/app/modules/:/path/to/www/lib/:.:/usr/local/share/pear"
I have ZF library in the /path/to/www/lib/ folder, so wtf?
This solved the problem:
chmod -R 755 /path/to/www/lib
Blimey!

Categories