0

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

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.

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.)

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()

Jozomby
  • 49
  • 8
  • When receiving errors, please always show the _complete_, _exact_ error message! – ndm Jan 29 '15 at 17:08
  • Thank you for the suggestion. I hadn't included it because quite literally, the only thing the error says is 'Class ___ not found' but I've added it above in case it helps. – Jozomby Jan 29 '15 at 17:22
  • It's especially helpful in this case as it makes it clear that, where, and how you are targeting the class incorrectly. – ndm Jan 29 '15 at 17:24

1 Answers1

1

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.

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.

In case you are not familiar with namespaces, you may want to start with: http://php.net/namespaces

ndm
  • 59,784
  • 9
  • 71
  • 110
  • Thank you for the answer. My copy of Cake has the plugin installer (assuming that's what vendor\cakephp\plugin-installer is) and I located the jasig/phpcas plugin at the packagist link that was provided in the CakePHP 3.0 documentation. Everything appears to be working just fine in that area. Adding the import seems to have fixed things for me. Thank you for the help; I spent a lot of time trying to research whether or not I needed an import, and how to do it, and couldn't find anything. – Jozomby Jan 29 '15 at 17:39
  • @Jozomby Updated my answer regarding the plugin installer, it was very misleading. packagist is the global composer repository, it's for everything! that uses composer, not just CakePHP (and its plugins), wich happens to be one of the many projects that are using composer as their dependeny manager. – ndm Jan 29 '15 at 18:02