I have updated my cakePHP application to 3.1 through composer, and I'm trying to fix all the small or deprecated warnings.
I could easily fix the $this->layout stuff but I don't understand how to fix viewPath errors.
Looking at the migration guide it looks like it should be exactly the same thing:
$this->viewPath = 'Element';
should become
$this->viewBuilder()->viewPath('Element');
But this is not working, and the only thing that I get is
Error: Call to undefined method Cake\View\ViewBuilder::viewPath()
File /var/www/myapp/src/Controller/InvoicesController.php
Line: 375
What is the correct way to fix this?
From the very same migration guide, in the View section of it:
View::$viewPath is deprecated. You should use View::templatePath() instead.
Guess it's now:
$this->viewBuilder()->templatePath('Element');
Related
I am trying to install React-Photo-Gallery and React-Images to get a lightbox gallery.
I am getting this error:
Error in ./~/react-scrolllock/dist/index.js
Module not found: [CaseSensitivePathsPlugin] /Users/anmareewilliams/Apps/anmaree/anmaree/node_modules/react-scrolllock/dist/Scrolllock.js does not match the corresponding path on disk ScrollLock.js.
# ./~/react-scrolllock/dist/index.js 7:18-41
I am not sure what I did wrong because I didn't touch anyting related to the Scrolllock and I am seeing that the Scrolllock.js is in fact named dist/ScrollLock.js
Any help would be much appreciated.
Thank you.
You haven't done anything wrong so far.
React-Images is using an old version of react-scrollock (4.0.1 latest is 5.0.0), which might be a problem.
Mootools and ExtJs have a compatibility issue when used on the same page. Mootools throws the following error :
Uncaught TypeError: Property 'id' of object #<HTMLDocument> is not a function
How can we use both frameworks side by side ? Is there a workaround ?
This looks like a document.id('..') reference issue, it is defined but it's not the mootools method...
Nothing will work if it's not pointed to the mootools method.
I would argue that ExtJS or your app has added a property id to document, which is not a function as is likely a String or another primitive.
Pretty sure that ExtJS would not have been overwriting document.id, especially given that they (Sencha) employed MooTools core team dev #subtlegradient (thomas aylott) who co-wrote the Slick selector engine and helped engineer the document.id transition in MooTools from the simple $ in 1.11
You probably cannot do document.id = $ to restore it as it's by reference and it's been overwritten.
Only chance is to try loading MooTools after ExtJS is loaded and started - or load MooTools, save a ref like document.$id = document.id; immediately after, load ExtJS and then restore it back when ready via document.id = document.$id; delete document.$id - still no guarantees this will run at the right time. you really need to see what modifies your document object in web inspector (you can add a watcher)
I am running an Apache2/PHP5 web server on my Mac (Mountain Lion). When I upgraded from Lion to Mountain Lion, I lost my dev environment/configs. Whilst trying to set everything up, I have somehow borked my httpd or php.ini configuration (I think, anyway)... when I point my browser to my localhost, I get the infamous PHP error:
Fatal error: Cannot redeclare (some random function).
Regardless of the page I point it to, I get this. Prior to the loss of my web server settings, this was not happening, so I am confident that the files are okay and all syntax is good (the whole site consistently uses include_once and require_once also).
I think it has to do with my virtual host setup or working directory setup... I've tried a number of things, but no joy so far.
I am happy to provide any/all info that would be useful... I'm at my wit's end on this. Any help or suggestions would be greatly appreciated.
You've most likely changed your include_path so you are loading the same php file using different paths. When you do this, php can't tell it's the same file, so it loads the file a second time, which causes the Cannot redeclare error.
One way to track down the problem is to add the following right before the offending line:
echo "<pre>";
print_r(explode(PATH_SEPARATOR, get_include_path()));
print_r(get_included_files());
Fatal error: Cannot redeclare (some random function)/class
Always Means that the function or class with the SAME name has been defined before,
Take a look at this example:
<?php
function test(){
return 1;
}
function test(){
return 2;
}
//will produce fatal error like yours
class A {}
class A {}
//Will say that it can't redeclare class A
Here's the clue you should start from
Make sure that:, your include path is set accordingly
To get some clue, try:
<?php
print_r ( get_included_files() );
?>
In my particular case, it happened to be a bad vhosts setup. Once I fixed a kind of redirect issue there, it solved the problem.
Both of the other answers (and comments) supplied here are VERY good though, and should help anyone with similar issues in the future debug their code. Very rarely will you goof up like I did with vhosts and run into this problem (but not a ton of others). Big thank you to Ross Smith II, metal_fan and Jeffrey for their help in this!
I've just fixed that problem looking in another forum.
In my case, te problem was that:
<?php
include "file.inc";
$user = new user()
....
?>
<?php
include "file.inc"
....
?>
I included two times "file.inc", and that was the problem. Juust keep the include in the "main" file and that's all!
i use cakephp and i am beginner
i use
$this->requestElement()
in
default.ctp
file but i face error.
but when use
$this->element()
my problem solved.
i face question that what is difference between $this->requestElement() and $this->element();
when i use requestElement() and when i use element() ?
thanks for help.
requestElement is outdated/deprecated (was used prior to 1.3).
you should now use element()
I'm not sure where you've found the method requestElement() but I can't find it in the API documentation. If the method ever existed it's likely been deprecated in later versions of Cake.
Or did you mean requestAction()?
You probably mean renderElement instead of requestElement. renderElement was deprecated in CakePHP 1.2, and has been removed in later versions.
I have upgraded my Xampp to newer version(1.7.2).But right now when I run my project(done in CakePHP) it is throwing bug saying
Deprecated: Assigning the return value of new by reference is deprecated in
C:\xampp\htdocs\ebayn\cake\libs\debugger.php on line 99
Deprecated: Assigning the return value of new by reference is deprecated in
C:\xampp\htdocs\ebayn\cake\libs\debugger.php on line 108
Deprecated: Assigning the return value of new by reference is deprecated in
C:\xampp\htdocs\ebayn\cake\libs\file.php on line 96
Deprecated: Assigning the return value of new by reference is deprecated in
C:\xampp\htdocs\ebayn\cake\libs\cache\file.php on line 89
Can anyone help me how can I rectify this stuff....???
Thanks In Advance
You need to patch the cake/libs/configure.php and find the line "error_reporting(E_ALL);" replace that line with the following:
error_reporting(E_ALL & ~E_DEPRECATED);
You may need to change this in your app/webroot/index.php and respectively test.php, too.
There is currently no better way than to touch the core.
You don't mention your CakePHP version, but if you use PHP 5.3 (which is part of Xampp 1.7.2) then you have to use CakePHP 1.3.x.x.
You haven't included any code, but it looks like you may be attempting to assign a variable by reference - probably an instance of an object. In PHP 5+, that's the default, as I recall. In 5.3, they may have officially deprecated the practice.
If your app has to work with PHP 4, you may want to look at your error_reporting setting. If E_STRICT is set, turn it off. I don't recall which settings effect which types of errors, but that particular value will probably be instructive if I were to guess.
I found I needed to roll PHP 5.3 back to php 5.2 in MAMP in order to run Cake 1.2.
Need to get a local copy of an old client site throwing useful errors, instead of just an Internal Server Error.
Progress...