CakePhp3.3 Error: Class 'CakeHaml\View\CakeHamlView' not found - cakephp

Pardon me as this is my first questions.
I tried to install a plugin for haml in cakephp 3 manually, and found this k-motoyan/cake-haml
I can't install it using composer because I use cakephp 3.3.*
k-motoyan/cake-haml dev-master requires cakephp/cakephp 3.0.*-dev ->
no matching package found.
So, I tried to install it manually, downloading the zip and put it in [app]/plugins/kmotoyan/cakephp
I follow the readme setup
Setup
Add plugin load line to config/bootstrap.php file:
diff
+ Plugin::load('CakeHaml', ['bootstrap' => true]);
Set the default ViewClass on the src/Controller/AppController.php
file:
```diff class AppController extends Controller {
public $viewClass = 'CakeHaml\View\CakeHamlView'; ```
You can use haml on all your view files with .haml extension.
and put this code below in my config/bootstrap.php
Plugin::load('kmotoyan/CakeHaml', ['bootstrap' => true]);
and this code below in my src/Controller/AppController.php
public $viewClass = 'CakeHaml\\View\\CakeHamlView';
when I load the server, i get this error
Error: Class 'CakeHaml\View\CakeHamlView' not found File
C:\xampp\htdocs\qolega\vendor\cakephp\cakephp\src\View\ViewBuilder.php
Line: 363
when I see line 363 there's this line
return new $className($request, $response, $events, $data);
what should I do?

Related

QrCode class not found or interface not found using Endroid/QrCode in Cakephp2.X

I'm new in cakePHP and I'm trying to run Endroid/QrCode in Cakephp2.x with no success. My controller looks like follows:
public function presta_my_function(){
App::import('Vendor', 'Endroid\QrCode', array('file' => 'Endroid/QrCode/QrCode.php'));
in this case I get the following error:
2017-09-27 02:11:55 Error: Fatal Error (1): Interface 'Endroid\QrCode\QrCodeInterface' not found in [C:\MAMP\htdocs\xxxx\app\Vendor\Endroid\QrCode\QrCode.php, line 18].
On the other hand, if try to do an import of QrCodeInterface.php before loading QrCode.php I get the following error:
2017-09-27 02:42:15 Error: Fatal Error (1): Class 'QrCode' not found in [C:\MAMP\htdocs\xxx\app\Controller\ActivitesController.php, line 971].
In this case the code looks like follows:
public function presta_my_space(){
App::import('Vendor', 'Endroid', array('file' => 'Endroid/QrCode/QrCodeInterface.php'));
App::import('Vendor', 'Endroid\QrCode', array('file' => 'Endroid/QrCode/QrCode.php'));
Endroid\QrCode is installed in /app/vendor/Endroid/QrCode.
Any idea about what is failing?
Thank you very much in advance.
You cannot include namespaced, composer based libraries like endroid/QrCode using App::import(), as this will only load a single file. Sure, you could load each and every single file manually, but that's anything but a good idea.
Switch your CakePHP application to using composer (back up your application before fiddling with this), and then ditch App::import() and use the library as shown in their docs.
See Cookbook > Installation > Advanced Installation

Josegonzalez/Upload.UploadBehavior could not be found cakephp 3.x

I have a problem configuring Josegonzalez plugin, i get an error as below
Josegonzalez/Upload.UploadBehavior could not be found.
Make sure your plugin Josegonzalez/Upload is in the C:\xampp\htdocs\sunelex\plugins\ directory and was loaded.
Error: Create the class UploadBehavior below in file: C:\xampp\htdocs\sunelex\plugins\Josegonzalez/Upload\src\Model\Behavior\UploadBehavior.php
<?php
namespace Josegonzalez\Upload\Model\Behavior;
use Cake\ORM\Behavior;
class UploadBehavior extends Behavior
{
}
I managed to get the plugin via composer into the plugins folder. I then enabled the plugin in the boostrap.php like Plugin::loadAll(); My table class behavior code looks as follows.
$this->addBehavior('Josegonzalez/Upload.Upload', [
'survey_step3_asbestos_pic' => [
'fields' => [
// if these fields or their defaults exist
// the values will be set.
'dir' => 'photo_dir', // defaults to `dir`
'size' => 'photo_size', // defaults to `size`
'type' => 'photo_type', // defaults to `type`
],
],
]);
Everything is in its place but for some reason I am getting the error above. Could you please help. Thanks.
Using cmd install below command.
composer require josegonzalez/cakephp-upload
You need to enable the plugin your config/bootstrap.php file:
<?php
Plugin::load('Josegonzalez/Upload');
If you are already using Plugin::loadAll();, then this is not necessary.

How to install a plugin manually in CakePHP 3?

I am unable to use Composer and thus have to install CakePDF plugin manually, but following examples from official CakePHP documentation does not seem to work.
So here is installation flow that I have followed:
1.) Copied the plugin to app/plugins/CakePdf
2.) Updated the app's composer.json file, like following:
"autoload": {
"psr-4": {
"CakePdf\\": "./plugins/CakePdf/src",
"CakePdf\\Test\\": "./plugins/CakePdf/tests"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests",
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
"CakePdf\\": "./plugins/CakePdf/src",
"CakePdf\\Test\\": "./plugins/CakePdf/tests"
}
}
3.) Loaded the plugin in bootstrap.php:
Plugin::load('CakePdf', ['bootstrap' => true, 'routes' => true, 'autoload' => true]);
4.) Added router extensions:
Router::extensions(['pdf']);
5.) Tried a very simple sample from plugin's doc:
$cakePdf = new CakePdf(array(
'engine' => 'CakePdf.DomPdf',
'pageSize' => 'A4',
'orientation' => 'portrait'
));
$html = '<html><head><body><p>Pdftest</p></body></head></html>';
$rawPdf = $CakePdf->output($html);
However the code breaks at the first line and the following error message is provided:
Class 'App\Controller\CakePdf' not found
I would really appreciate any help or guidance for how a plugin should be installed manually.
If there is any other information that I need to provide, just ask.
You are getting this error because inside vendor/composer/ you can see some autoload_*.php files. These files hold the paths to load your classes. I think no one can safely tell you what to update and where in these files.
So you have two solutions:
1 - Copy composer.json on a local machine and run composer update. Then move the files created inside your app. I would suggest to take a backup before. Most probably the things that you will have to move are:
vendor/
composer.json
composer.lock
2 - Start updating the files inside vendor/composer/autoload_*.php with the paths from the plugin. Most probably you will only need to update the following two files:
vendor/cakephp-plugins.php and vendor/composer/autoload_psr4.php. Personally I wouldn't choose the second solution I am just adding it as an alternative just in case.

Asset Compress Plugin for CakePHP not working

I'm having troubles to compress my Javascript files using Asset Compress Plugin for CakePHP 2.X. I'm currently using CakePHP 2.2.2 over IIS 7.
It tries to add the compressed js file but it doesn't exist:
<script type="text/javascript" src="/cakephp/cache_js/jquery-combined.v1379067166.js">
I have downloaded and placed the plugin under app/Plugin/AssetCompress/
I have dowloaded YUI build tool and placed the file contained in lib/yuicompressor/yuicompressor-2.4.2 in vendors/yuicompressor/
I have made the folder webroot/cache_js/ writable.
This is my asset_compress.ini:
[General]
cacheConfig = false
[js]
timestamp = true
path = WEBROOT/js/*
cachePath = WEBROOT/cache_js/
filters[] = YuiJs
[jquery-combined.js]
files[] = jquery.tipsy.js
files[] = web.js
And I am adding the plugin in bootstrap like this with debug mode set to 0:
Configure::write('Dispatcher.filters', array(
'AssetDispatcher',
'CacheDispatcher'
));
CakePlugin::load('AssetCompress', array('bootstrap' => true));
Also, I'm loading it from the AppController:
var $helpers = array('AssetCompress.AssetCompress');
And using it on the layout template in this way:
echo $this->AssetCompress->script('jquery-combined');
The only error I'm getting on the error.log is the following one:
2013-09-13 14:16:10 Error: [MissingControllerException] Controller
class CacheJsController could not be found.
C:\inetpub\wwwroot\cakephp\app\webroot\index.php(92): Dispatcher-> dispatch(Object(CakeRequest), Object(CakeResponse))
C:\inetpub\wwwroot\cakephp\index.php(42): require('C:\inetpub\wwwr...')
{main}
Any clue about what can be happening?
Should I have Java SDK installed ? Am I picking the wrong .jar file from YUI?
Thanks.
Before you can set debug = 0 you need to use the CLI tool to build static versions of the assets. I'm pretty sure this is in the documentation.

Cakephp Media Plugin Problem

I am trying to use the Media Plugin (http://www.ohloh.net/p/cakephp-media)
I placed the media folder contents in app/plugins/media
then in bootstrap.php in the app/config/ folder added the following code.
Configure::load('media.core');
Now when i run any controller and any action am getting the following error.
Configure::load() - no variable $config found in core.php [CORE\cake\libs\configure.php, line 266]
I am using Cakephp 1.3.7
loading config files with cakes Configure::load() has a requirement that the configs be in a variable called $config
eg
<?php
$config['Meh'] = array('foo' => 'bar');
?>

Resources