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";
Related
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
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
I worked with a project using composer.But when i run the index file,system shows the following error,
Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in D:\xampp\htdocs\instagram_php\index.php on line 5
Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs\instagram_php\index.php on line 5
I have installed composer from https://getcomposer.org/.
What am doing wrong?
You are using require_oncewith a relative path. It is possible but there are so many things that can go wrong that I usually avoid it.
Where is the vendorfolder relative to index.php? I recommend using an absolute path. You can use the magic constants to determine it:
require_once(__DIR__ . '/vendor/autoload.php');
NOTE: you can use /.. to go up the directory tree.
NOTE2: __DIR__ requires php 5.3 or higher. You can use dirname(__FILE__) for older versions.
Make sure vendor folder is there if not please Run following command:-
composer install
I installed the pear/http_request2 version 2.2.1 using Composer in my project but when I am trying to make my first request I am getting this Warning and Fatal error:
Warning: require_once(Net/URL2.php): failed to open stream: No such
file or directory in
/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php
on line 24
Fatal error: require_once(): Failed opening required 'Net/URL2.php'
(include_path='/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/pear_exception:.:/Applications/XAMPP/xamppfiles/lib/php')
in
/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php
on line 24
I appreciate any help on how to fix it, thanks in advance.
David.
This should work:
composer require pear/http_request2:2.2.1
By default pear/net_url2 should be installed which has the required URL2.php file (./vendor/pear/net_url2/Net/URL2.php).
Then make sure you're including vendor/autoload.php file in your scripts to load automatically the include paths (see: vendor/composer/include_paths.php file).
Here is a simple PHP command to test this out:
php -r 'require_once "vendor/autoload.php"; require_once "Net/URL2.php";'
Note: The above command should run without any errors.
Related: Errors in the autoloaded HTTP/Request2 code, how to troubleshoot composer?
You need HTTP_Request2 from git master, because it has not been released/tagged yet at the time of writing.
I have included autoload.php in the header of my site
include 'vendor/autoload.php';
From this i am receiving the following errors on my site:
Warning: require_once(DIR/composer/autoload_real.php)
[function.require-once]: failed to open stream: No such file or
directory in
/homepages/6/d416629391/htdocs/leftovercheese/vendor/autoload.php on
line 5
Fatal error: require_once() [function.require]: Failed opening
required 'DIR/composer/autoload_real.php'
(include_path='.:/usr/lib/php5') in
/homepages/6/d416629391/htdocs/leftovercheese/vendor/autoload.php on
line 5
My code is:
// autoload.php generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit8be239f5caef32db03f87bb271ed6012::getLoader();
PHP Version: 5.2.17
Any ideas?
run composer install
That will import your packages and create the vendor folder as well as the autoload script. Also, make sure your relative path is correct.
You have to load vendor/autoload.php, which will autoload that file for you:
require_once __DIR__ . '/vendor/autoload.php';
This is assuming that your file is located at the same directory level as the vendor directory.
Otherwise, adjust.
For me, I updated some folder names and these updated are not reflected in autoload_files.php and autoload_static.php. I just had to run php composer.phar dump-autoload.