Error loading cakephp 2 plugin - php

I installed a plugin in CakePHP from Upload, I loaded it into in app / Config / bootstrap.php. thus
CakePlugin::load('Upload'); but I'm getting the error below, do I need to do anything else? CakePHP 2.0
Error: Upload.UploadBehavior could not be found.
Error: Create the class UploadBehavior below in file: C: \ xampp \
htdocs \
This class already exists in the plugin!

From the Upload Plugin Github Page:
This plugin work as a behaviour for your model so you have to attach it to your model
public $actsAs = array(
'Upload.Upload' => array(
'fields' => array(
'thumb' => 'img/posts/:id1000/:id'
)
)
);

Related

Cakephp prefix routing not working on Linux - but works on Windows

I have a CakePHP 3 app and it has different plugins. The plugins appear to load and accessing them on a dev Windows machine, WAMP, it all works fine.
Once on the CentOS server, the plugin's prefix routing eg 'admin' stops working, getting a missing controller error:
Log error:
2018-04-11 12:40:23 Error: [Cake\Routing\Exception\MissingControllerException] Controller class Contacts could not be found.
Exception Attributes: array (
'class' => 'Contacts',
'plugin' => 'Contacts',
'prefix' => 'admin',
'_ext' => NULL,
)
Request URL: /myapp/contacts/admin/contacts
Referer URL: https://***/myapp/anotherplugin/participants
Stack Trace:
#0 /srv/www/myapp/myapp-app/webroot/index.php(36): Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#1 /srv/www/myapp/myapp-app/index.php(16): require('/srv/www/mya...')
#2 {main}
The controller does exists and contains:
namespace Contacts\Controller\Admin;
use Contacts\Controller\AppController;
use Cake\ORM\TableRegistry;
use Authentication\Utility\TimeUtility;
use Cake\I18n\Time;
use Cake\Core\Configure;
class ContactsController extends AppController{
Non-prefix routing seems fime. The plugins are added in bootstrap.php like this:
Plugin::load('Contacts', ['bootstrap' => false, 'routes' => true]);
In plugins routing file:
<?php
use Cake\Routing\Router;
Router::plugin('Contacts', function ($routes) {
$routes->fallbacks('InflectedRoute');
});
Router::plugin('Contacts', function ($routes) {
$routes->prefix('admin', function ($routes) {
$routes->fallbacks('InflectedRoute');
});
});
In Apache the app is setup as an alias with mod rewrite - both on WAMP and on the CentOS server:
http://server-or-localhost/myapp/
Differences between local and server:
Server is Linux, uppercase/lower case issues?
Same PHP versions, but
maybe some modules missing on server PHP?
The server redirects http to https
Blast! Check your CakePHP version 3.2.0 has this bug. Fixed in 3.2.1.
https://bakery.cakephp.org/2016/01/30/cakephp_3110_and_321_released.html
It's working now.

How to manually install chat module in Humhub

I just installed humhub and downloaded the chat module from github. https://github.com/ychoucha/HUMHUB-module-chat
I gitcloned it to humhub/protected/modules. But, it does not show up in the modules section of administration login. How do I install this or other third part modules in Humhub?
According to this link https://github.com/humhub/humhub/issues/165 on Sep 12, 2014, Luke said:
You can also install modules manually:
Download Module (e.g. mail)
Put it into protected/modules/mail
Enable it in Administration -> Modules
I've tried with the Tasks modules and it worked. Make sure you have the latest stable version of the code from the Humhub repository. You also must be able to download that directly from the Administration > Modules > Find Online
The module no longer works since humhub v1.0.
According to the docs you need to add a config.php file.
https://www.humhub.org/docs/guide-dev-module.html
config.php (replaces autostart.php)
<?php
use humhub\modules\dashboard\widgets\Sidebar;
return [
'id' => 'chat',
'class' => 'humhub\modules\chat\ChatModule',
'namespace' => 'humhub\modules\chat',
'events' => [
array(
'class' => Sidebar::className(),
'event' => Sidebar::EVENT_INIT,
'callback' => array(
'humhub\modules\chat\ChatModule',
'onSidebarInit'
)
),
],
];

Yii RBAC issue in putty

In the slides im reading for creating user auth i have to install rbaccommand.php in the protect/commands/shell folder.
My Rbac is the one found here http://pastebin.com/uENRQ5Nz
i have this in my config/main.php
'authManager'=>array(
'class' => 'CDbAuthManager',
'connectionID' => 'db',
),
and this is the line i put into the command line. php yiic.php shell config/main.php i'm supposed to type yes afterwards but it states rbac isn't found.
Am i missing a step?
Sam

Laravel: Helpers class not found on live site. Works locally

I am attempting to use the thujohn/twitter package to get a live twitter feed on my site.
I got it working on my local server by using the tutorial found here but when I uploaded the changes to my digital Ocean server, I got the error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Helpers' not found
Here are the steps I took - not much code:
I downloaded the package with artisan
config/app.php: added 'Thujohn\Twitter\TwitterServiceProvider', to the providers and 'Twitter' => 'Thujohn\Twitter\TwitterFacade' to the aliases
added app_path().'/classes', to the start/global.php file
I added a Helpers class to classes/helpers.php, which contains:
public static function twitterFeed($screen_name='screenName', $count='1', $include_retweets='false', $exclude_replies='true')
{
$twitterfeed = Cache::remember('twitterfeed', 30, function() use ($screen_name, $count, $include_retweets, $exclude_replies) {
return Twitter::getUserTimeline(
array(
'screen_name' => $screen_name,
'count' => $count,
'include_rts' => $include_retweets,
'exclude_replies' => $exclude_replies
)
);
})
;
if(!empty($twitterfeed)) {
return $twitterfeed;
}
else {
return array();
}
}
Put a view::share in my route file:
View::share('tweets', Helpers::twitterFeed('contractrsherpa', '1', false, true));
then looped through it in my view.
Finally, ran composer dump-autoload.
Seems pretty straightforward and works great locally. I uploaded everything to my liver server, ran composer dump-autoload, but still get the error "class 'Helpers' not found."
Any idea what I need to do to get this to work on the live site?
TIA

Using registerNamespaces() in autoload.php

I use Symfony and I need to add couple bundles in my autoload.php file, which is in .../app/ folder.
So, I basically wrote this:
<?php
// [snip]
use Doctrine\Common\Annotations\AnnotationRegistry;
$loader->registerNamespaces(array(
'Behat\BehatBundle' => '/var/www/testsuite.behat/vendor',
'Behat\Behat' => '/var/www/testsuite.behat/vendor/Behat/Behat/src',
'Behat\Gherkin' => '/var/www/testsuite.behat/vendor/Behat/Gherkin/src',
'Behat\Mink' => '/var/www/testsuite.behat/vendor/Behat/Mink/src',
'Behat\MinkBundle' => '/var/www/testsuite.behat/vendor',
'Goutte' => '/var/www/testsuite.behat/vendor/Goutte/src',
'Zend' => '/var/www/testsuite.behat/vendor/Zend/library',
'Behat\SahiClient' => '/var/www/testsuite.behat/vendor/Behat/SahiClient/src',
'Buzz' => '/var/www/testsuite.behat/vendor/Buzz/lib'
));
$loader->register();
And when I run php app/console it shows me the error:
PHP Notice: Undefined variable: loader in /var/www/~/app/autoload.php on line 6
PHP Fatal error: Call to a member function registerNamespaces() on a non-object in /var/www/~/app/autoload.php on line 6
where "~" is my project's name.
Please, help me with this problem.
Considering you have version 2.1 or higher, this isn't needed anymore. 3th party bundles should be installed via composer, which will take care of the autoloading. This step is only needed for 2.0 versions, as those use the old vendor script created by symfony.
If you, for some reason, still need to register some namespaces, you should do that in your composer.json file:
{
...
"autoload": {
"psr-0": {
"My\\Namespace": "path/to/me"
}
}
}
More information: http://getcomposer.org/doc/04-schema.md#psr-0

Categories