使用composer时init.php中需要_once路径错误
嗨,朋友,这是我的文件夹结构使用composer时init.php中需要_once路径错误,php,authentication,composer-php,Php,Authentication,Composer Php,嗨,朋友,这是我的文件夹结构 googleauth -app --classes ---googleauth.php --init.php -vendor --autoload.php 我在init.php中给出了以下路径 require_once 'vendor/autoload.php'; require_once 'classes/GoogleAuth.php'; 然后错误显示为 Warning: requi
googleauth
-app
--classes
---googleauth.php
--init.php
-vendor
--autoload.php
我在init.php中给出了以下路径
require_once 'vendor/autoload.php';
require_once 'classes/GoogleAuth.php';
然后错误显示为
Warning: require_once(vendor/autoload.php): failed to open stream: No such
file or directory in C:\xampp\htdocs\tutorials\googleauth\app\init.php on
line 5
Fatal error: require_once(): Failed opening required 'vendor/autoload.php'
(include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\tutorials\googleauth\app\init.php on line 5
因此,我如何通过为文件提供正确的路径来解决它呢?您必须使用
../vendor/autoload.php'
,因为路径来自运行它的文件。您必须使用'../vendor/autoload.php'
,因为路径来自运行它的文件。代码下面的用户
需要_once'../vendor/autoload.php';//“.”用于父目录需要_once./classes/GoogleAuth.php';//“.”表示同一目录 如果您使用的是linux(区分大小写),那么文件名将是相同的。比如,如果文件名是“googleauth.php”,那么就不能将其用作“googleauth.php” 下面的用户代码 需要_once'../vendor/autoload.php';//“.”用于父目录
需要_once./classes/GoogleAuth.php';//“.”表示同一目录
如果您使用的是linux(区分大小写),那么文件名将是相同的。比如,如果文件名是“googleauth.php”,那么就不能将其用作“googleauth.php” 另请注意,对于文件名
GoogleAuth
vsGoogleAuth
,请始终使用正确的大小写。您的应用程序可以在windows上运行,但如果有时您将代码移动到非windows平台,它也会崩溃。请注意,对于文件名GoogleAuth
vsGoogleAuth
,始终使用正确的大小写。您的应用程序可能在windows上运行,但如果您将代码移动到非windows平台,它将中断