使用CakePHP 3.0插件 [英] Using CakePHP 3.0 plugin
问题描述
我目前正在使用3.0.0-RC1版本构建一个新的CakePHP应用,并尝试安装和使用jasig / phpCAS插件。使用本指南,我已经从命令提示符处运行了以下命令: composer需要jasig / phpcas
I'm currently building a new CakePHP app with version 3.0.0-RC1, and trying to install and use the jasig/phpCAS plugin. Using this guide, I've run the following command from the command prompt: composer require jasig/phpcas
这可以将jasig / phpcas文件正确复制到我的应用程序的供应商目录中,但是一个指南说应更新的其他文件(vendor / cakephp-plugins.php)甚至不存在。
This correctly copies the jasig/phpcas files into the vendor directory of my app, but one of the other files that the guide says should be updated (vendor/cakephp-plugins.php) doesn't even exist.
我在使用插件时遇到了困难。我希望能够调用其静态方法,并且不断收到以下形式的错误:错误:找不到 App\Controller\phpCAS类
。 (错误中的确切目录会根据我从何处调用该方法而变化。)
I've had a tough time accessing the plugin. I want to be able to call its static methods, and I keep getting errors of the form: Error: Class 'App\Controller\phpCAS' not found
. (The exact directory in the error changes depending on where I'm calling the method from.)
我不知道这是否是由于没有cakephp- plugins.php文件,或者如果我没有正确调用插件。据我了解,如果加载了插件,我应该能够像这样调用静态方法: phpCAS :: methodName()
I don't know if this is due to not having the cakephp-plugins.php file, or if I'm not calling the plugin correctly. It's my understanding that if the plugin is loaded I should just be able to call static methods on it like this: phpCAS::methodName()
推荐答案
首先 jasig / phpcas
不是CakePHP插件。并且 vendor / cakephp-plugins.php
文件是由CakePHP插件安装程序创建的,因此,如果您没有看到这样的文件,则可能未安装任何文件。插件尚未安装,或者您尚未使用安装程序的最新版本,因为该文件的创建是最近才引入的。
First of all jasig/phpcas
is not a CakePHP plugin. And the vendor/cakephp-plugins.php
file is created by the CakePHP plugin installer, so if you don't see such a file, you seem to have either not installed any plugins yet, or you are not using a recent version of the installer, as the creation of this file has been introduced just recently.
关于类未出现的错误找到,您缺少用于访问全局名称空间中的类的前导名称空间分隔符( \phpCAS :: methodName()
),分别缺少正确的导入(使用phpCAS;
)将使类在当前名称空间中可用。
Regarding the error about the class not being found, you are missing the leading namespace separator (\phpCAS::methodName()
) to access the class in the global namespace, respectively you are missing a proper import (use phpCAS;
) that would make the class available in the current namespace.
如果您不熟悉名称空间,您可能要以: http://php.net/namespaces
In case you are not familiar with namespaces, you may want to start with: http://php.net/namespaces
这篇关于使用CakePHP 3.0插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!