I installed tha cakephp Utils plugin via composer, and then I loaded all plugins in my bootstrap.php file, I added a field in my database model for the image path (cause I want to upload image profile using Uploadable), and then I add the following code I my model table:
$this->addBehavior('Utils.Uploadable', [
'foto_dir',
]);
but when I access the model I get the following error:
Utils.UploadableBehavior could not be found.
Make sure your plugin Utils is in the C:\wamp\www\siec2\plugins\ directory and was loaded.
Screenshot:
Please help.
Plugins installed with composer are stored inside the vendor folder. Please make sure, you have the Utils Plugin in the following folder /vendor/cakemanger/cakephp-utils
If so, check cakephp-plugins.php inside the vendor folder for this:
return [
'plugins' => [
...
'Utils' => $baseDir . '/vendor/cakemanager/cakephp-utils/'
]
];
Also make sure, you loaded the plugin in your bootstrap.php: Plugin::load('Utils');
See Plugins Section on CakeBook.
Related
I have just updated my composer and after that when i run my Yii2 application i got this error "Class dektrium\rbac\Module does not exist" i am using rbac in my application.
I checked desctrium\rabc directory there is no file with Module class. However i can see two new files RbacWebModule, RbacConsoleModule in that directoy.
I have a backup of my application on other server. so do i have to put my backup there to correct this error or is there any other solution. i can see in my vendor folder all other folders also get updated with composer update. So how to get rid of this error.
Thanks in advance.
This class has been renamed over a month ago. Since it's still beta I recommend to check for any major changes with every upgrade. Always follow the instruction.
Add rbac module to web application config file as follows:
...
'modules' => [
...
'rbac' => 'dektrium\rbac\RbacWebModule',
...
],
...
I moved working plugin from /plugins/pluginname directory to /vendor/myname/pluginname
URL on which I call plugin controller is
http://domain.local/pluginname/index
Before moving from first directory to another, plugin was working as expected. I moved plugin to new directory to make it reusable for other cake PHP apps.
Plugin is installed by composer.
Why do I have message
"Error: Controller class Index could not be found.". All controllers
from plugin are not visible on app, throws the same error. Error is
thrown from line 79 from file
\vendor\cakephp\cakephp\src\Routing\Dispatcher.php
In main bootstrap.php file I put this line:
Plugin::load('MyName/PluginName', ['bootstrap' => false, 'routes' => true]);
Why plugin in vendor directory is not working in my case?
If plugin is installed by Composer, do not move it.
Whether it is installed at the plugin or vendor folder is determined by the author of the plugin.
If you need to fully load the Plugin in your bootstrap, simply use
Plugin::load('PluginName', ['bootstrap' => false, 'routes' => true]);
See http://book.cakephp.org/3.0/en/plugins.html#plugin-configuration
It will simply work regardless if Composer places it in vendor or plugins folder.
Most importantly, leave it in the folder that the author intended it to be in.
Lastly, check that your plugin is suitable for CakePHP 3.x
As for the url, you should expect to use /plugin-name/controller/action
See http://book.cakephp.org/3.0/en/plugins.html#plugin-controllers and I quote
If you want to access what we’ve got going thus far, visit /contact-manager/contacts
You can try by setting autoload variable true.Add below code in bootstrap.php, clear cache and then check.
Plugin::load('PluginName', ['autoload' => true]);
I've been looking at all the related questions of this topic and none of the solutions provided (usually App::import() ) have worked for me, maybe because I have a different configuration, which is the following:
I have a regular cake installation which loads components from an external folder (so outside this installation). That works perfectly, even for the component I'm trying to use now (it works fine until I try to load the Vendor class). This Vendor class I want to have it outside the Cake installation as well (same as with the components). This is how this installation looks:
[root]
.......[shared_resources]
......................................[CakePHP]
........................................................[Components]
..............................................................................MyCustomComponent.php
........................................................[Vendor]
....................................................................[MyVendor]
......................................................................................MyVendor.php
......[MySite]
................... [cakephp typical folder structure]
In my site's bootstrap.php file I have App::build(array('Controller/Component' => array(dirname(ROOT) . '/shared_resources/CakePHP/Component/'))); in order to be able to load that component in any controller, which works fine, any component I put in that folder loads and works without issues.
Now, I'm trying to load the MyVendor class in the MyCustom component, but I can't get it to work, no matter what I try I keep getting class not found errors when trying to instantiate it.
I've tried using php's and Cake's require(), import(), App::import() and App::uses() with all possible combinations of paths (absolute and relative) without any success, puttin them before the declaration of the component class and inside the method that actually uses the vendor class. The last one I've tried is App::import('Vendor', '/absolute/path/to/shared_resources/Vendor/MyVendor/MyVendor.php'); for example.
I've also tried using App::build(array( 'Vendor' => array(dirname(ROOT) . '/shared_resources/CakePHP/Vendor/'))); in the bootstrap file, like with the components.
I don't know what else to try, any help would be much appreciated!!!
Oh, I've check with PHP that the file Vendor class file exists in that path too.
According to your folder structure,
To access your MyVendor.php, you should write like this
App::import('Vendor', 'MyVendor', array('file' => 'MyVendor/MyVendor.php'));
For more information, read http://book.cakephp.org/2.0/en/core-utility-libraries/app.html
In cakephp how can I access a file, inside vendor folder?
I am not using app folder. I have created another project folder with same structure of app.
Should I use the same
App::import('Vendor','phpseclib0.3.6/Net/SSH2.php');
statement or anything else.
Vendors libs should follow some name conventions. For libs with custom names us the following:
App::import(
'Vendor',
'aUniqueIdentifier',
array('file' => 'phpseclib0.3.6/Net/SSH2.php')
);
And read section Loading Vendor Files
I'm using the asset library that comes with pyrocms for my cms and I have a set up like this for my assets. I am trying to figure out with the paths and namespacing how I can access the bootstrap.css file correctly with the documentation.
http://docs.pyrocms.com/2.1/manual/developers/tools/assets
I have updated my asset.php configuration file to look like this:
$config['asset_paths'] = array(
'core' => 'assets/',
'globals' => 'assets/globals/'
);
This is the line I have set up in my template page to try and retrieve the bootstrap file:
<?php Asset::css('globals::bootstrap/css/bootstrap.min.css'); ?>
This is my file directory:
/root
/assets
/globals
/bootstrap
/css
bootstrap.css
It is saying the following error message.
Found no files matching
assets/globals/css/bootstrap/css/bootstrap.min.css
Any ideas on what I good fix would be for this?
I've never used the library in question, but judging on your post it appears that the library automatically checks for a css folder within the designated asset_path.
I would create a new asset path called bootstrap:
'bootstrap' => 'assets/globals/bootstrap/'
and add the CSS file as such:
Asset::css('bootstrap::bootstrap.min.css');