Php 使用未找到codeigniter类的oauth2客户端
我正在尝试使用来自的oauth2客户端 我通过composer安装了这个包,它在我的根目录中创建了一个供应商文件夹,其中包含league包。 然后我将其复制到我的应用程序/第三方/供应商文件夹中 在我的控制器中,我尝试执行以下操作:Php 使用未找到codeigniter类的oauth2客户端,php,codeigniter,oauth-2.0,composer-php,Php,Codeigniter,Oauth 2.0,Composer Php,我正在尝试使用来自的oauth2客户端 我通过composer安装了这个包,它在我的根目录中创建了一个供应商文件夹,其中包含league包。 然后我将其复制到我的应用程序/第三方/供应商文件夹中 在我的控制器中,我尝试执行以下操作: <?php defined('BASEPATH') or exit('No direct script access allowed'); class APl extends MY_Controller { public function __con
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class APl extends MY_Controller
{
public function __construct()
{
parent::__construct();
// Force SSL
$this->force_ssl();
// Form and URL helpers always loaded (just for convenience)
$this->load->helper('url');
$this->load->helper('form');
//Load Libraries
$this->load->library('managers/NameManager');
$this->load->library('managers/BreadcrumbManager');
}
public function aPLogin() {
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
}
}
在我的index.php文件中,如下所示:
require FCPATH . 'third_party\vendor\autoload.php';
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*/
require_once BASEPATH.'core/CodeIgniter.php';
我尝试通过以下方式更改FCPATH要求:
require_once APPPATH.'third_party\vendor\autoload.php';
还尝试:
include_once BASEPATH.'../application/third_party/vendor/autoload.php';
那么我要么得到:
Fatal error: require(): Failed opening required 'D:\wamp\www\codeigniter\third_party\vendor\autoload.php' (include_path='.;C:\php\pear') in D:\wamp\www\codeigniter\index.php on line 311
或
我只是想向你展示一下我使用你试图使用的软件包的过程。我重新安装了CodeIgniter,然后执行了以下操作 首先,我在config/config中设置composer自动加载:
$config['composer_autoload'] = TRUE;
{
"minimum-stability": "dev",
"require": {
"league/oauth2-client": "2.2.1"
}
}
cd /path/to/application
composer install
public function oauth_test()
{
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
echo '<pre>';
var_dump( $provider );
echo '</pre>';
}
接下来是一个最小composer.json,位于APPPATH:
$config['composer_autoload'] = TRUE;
{
"minimum-stability": "dev",
"require": {
"league/oauth2-client": "2.2.1"
}
}
cd /path/to/application
composer install
public function oauth_test()
{
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
echo '<pre>';
var_dump( $provider );
echo '</pre>';
}
从命令行:
$config['composer_autoload'] = TRUE;
{
"minimum-stability": "dev",
"require": {
"league/oauth2-client": "2.2.1"
}
}
cd /path/to/application
composer install
public function oauth_test()
{
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
echo '<pre>';
var_dump( $provider );
echo '</pre>';
}
然后,在我的欢迎控制器中,我放了这样一句话:
$config['composer_autoload'] = TRUE;
{
"minimum-stability": "dev",
"require": {
"league/oauth2-client": "2.2.1"
}
}
cd /path/to/application
composer install
public function oauth_test()
{
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
echo '<pre>';
var_dump( $provider );
echo '</pre>';
}
因此,你所做的任何超出这一范围的事情都是不必要的。如果是我,我想我会尝试删除整个供应商目录,然后再试一次。另外,我注意到您使用的是Windows,虽然我认为这不重要,但我使用的是Linux(这是大多数web代码的生产环境)。我只是想向您展示我使用您尝试使用的软件包所需的时间。我重新安装了CodeIgniter,然后执行了以下操作 首先,我在config/config中设置composer自动加载:
$config['composer_autoload'] = TRUE;
{
"minimum-stability": "dev",
"require": {
"league/oauth2-client": "2.2.1"
}
}
cd /path/to/application
composer install
public function oauth_test()
{
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
echo '<pre>';
var_dump( $provider );
echo '</pre>';
}
接下来是一个最小composer.json,位于APPPATH:
$config['composer_autoload'] = TRUE;
{
"minimum-stability": "dev",
"require": {
"league/oauth2-client": "2.2.1"
}
}
cd /path/to/application
composer install
public function oauth_test()
{
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
echo '<pre>';
var_dump( $provider );
echo '</pre>';
}
从命令行:
$config['composer_autoload'] = TRUE;
{
"minimum-stability": "dev",
"require": {
"league/oauth2-client": "2.2.1"
}
}
cd /path/to/application
composer install
public function oauth_test()
{
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
echo '<pre>';
var_dump( $provider );
echo '</pre>';
}
然后,在我的欢迎控制器中,我放了这样一句话:
$config['composer_autoload'] = TRUE;
{
"minimum-stability": "dev",
"require": {
"league/oauth2-client": "2.2.1"
}
}
cd /path/to/application
composer install
public function oauth_test()
{
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
'clientSecret' => 'demopass', // The client password assigned to you by the provider
'redirectUri' => 'http://example.com/your-redirect-url/',
'urlAuthorize' => 'http://brentertainment.com/oauth2/lockdin/authorize',
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource'
]);
echo '<pre>';
var_dump( $provider );
echo '</pre>';
}
因此,你所做的任何超出这一范围的事情都是不必要的。如果是我,我想我会尝试删除整个供应商目录,然后再试一次。另外,我注意到您使用的是Windows,虽然我认为这不重要,但我使用的是Linux(这是大多数web代码的生产环境)。您的主要问题是CodeIgniter希望您的供应商目录位于应用程序目录内。这就是composer.json文件所属的位置,也是运行composer命令安装/更新软件包的位置。@BrianGottier谢谢您的回答,我的目录结构是这样的:这就是它不工作的原因。供应商目录必须与第三方处于同一级别。codeigniter将自动运行autoload.php,所以您不必自己运行。@BrianGottier我将供应商文件夹移到了第三方之外,所以现在看起来是这样的:现在在我的配置中,我只需要$config['composer\u autoload']=TRUE;在我的index.php中,我也需要一些东西吗?您只需要
$config['composer\u autoload']=TRUE代码>。您需要将composer.json文件设置为与/vendor/
和/third\u party/
相同的级别。完成此操作后,请运行composer安装和/或更新,因为composer需要更新所有软件包的路径。您的主要问题是CodeIgniter希望您的供应商目录位于应用程序目录内。这就是composer.json文件所属的位置,也是运行composer命令安装/更新软件包的位置。@BrianGottier谢谢您的回答,我的目录结构是这样的:这就是它不工作的原因。供应商目录必须与第三方处于同一级别。codeigniter将自动运行autoload.php,所以您不必自己运行。@BrianGottier我将供应商文件夹移到了第三方之外,所以现在看起来是这样的:现在在我的配置中,我只需要$config['composer\u autoload']=TRUE;在我的index.php中,我也需要一些东西吗?您只需要$config['composer\u autoload']=TRUE代码>。您需要将composer.json文件设置为与/vendor/
和/third\u party/
相同的级别。完成后,请运行composer安装和/或更新,因为composer需要更新所有程序包的路径。这对我很有用!我不确定我以前做错了什么,但这确实起了作用。非常感谢你!这对我有用!我不确定我以前做错了什么,但这确实起了作用。非常感谢你!