CakePHP Migration Errors - php

I'm migrating my CakePHP site from a local Xampp installation to an EC2 ubuntu environment. I moved over the DB, and copied the web directory files over to the EC2 instance, but upon accessing the site I get this error:
Fatal error: Class 'AppController' not found in /var/www/cakephp/lib/Cake/Controller/CakeErrorController.php on line 31
I looked into the Apache error log and found that the piece it wasn't liking was this:
$this->Auth->user()['role']
The error said the PHP parser wasn't expecting the '['. This all worked fine in the default local Xampp install, so I'm assuming this is a PHP difference between the two installs?
Xampp: PHP 5.4.7
EC2: PHP 5.3.10
Any idea of any settings or anything that could cause this behavior?

That is a new feature in php 5.4 see http://docs.php.net/manual/en/migration54.new-features.php the third bullet item.
For php 5.3 you will need to assign it to a variable
$user = $this->Auth->user()
$role = $user['role'];

Related

Call to undefined function iconv_strpos() laravel 5.2

I'm trying to get a site up and running on a VPS server running cpanel.
I've uploaded the site and configured to point at the public folder which appears to be working (or pointing to the right folder)
However I'm getting a 500 server error. In an error_log I'm getting this error:
[18-Aug-2016 21:44:09 UTC] PHP Fatal error: Call to undefined function Symfony\Polyfill\Mbstring\iconv_strpos() in /home/spadsdrama/public_html/vendor/symfony/polyfill-mbstring/Mbstring.php on line 351
SO it looks like PHP is missing this function?
PHP version is 5.6
Laravel 5.2
Pulling out my hair to get this sorted
I had this site working correctly on a Plesk server but switched to a Cpanel one (might be regretting this now!)
What am I missing - what configuration is missing?
Thanks
You need to install http://php.net/manual/en/book.iconv.php PHP extension for this function support. You can do this from ISP-manager of VPS, if it exists, or with SSH console server.

when i upgrade php version 5.4 after codeigniter site give 500 error

I have some trouble when I upgrade PHP version 5.4 on my site. My site is built with CodeIgniter framework. It's working fine in previous version. When I check error log I see this error
error: cannot stat directory: (root_directory/project name/index.php/home)
Premature end of script headers: php54-cgi
cannot stat directory
It is linux error, not the PHP. In most common case after upgrading PHP you have changed user and/or group running php binary and new one simply does not have permissions to code directory.
So the answer will be - change user/group thats's running php.

installing egroupware 14.1 on ubuntu 14.04 running 5.5.9

fresh installation of egroupware 14.1 final on ubuntu server 14.04 gives following error;
Cannot redeclare class egw in
/.../web/phpgwapi/inc/class.egw.inc.php on
line 37
up to now I have been using egroupware for project management without any problems. To find the source of this issue, I went into sources. placed an echo at top of class.egw.inc.php and found out that it is included only once. checked if a class with same name exists elsewhere with regex search and cannot find any. checked class autoloading functions. it is possible that I have some configuration missing (like mbstring) but in previous installations, setup script was giving warnings about them. This time it is only a blank screen with a error message in the logs.
this is a PHP problem may be related to specific version. But this is the latest version for ubuntu 14.04 currently.
solution is to replace places of classes in /phpgwapi/inc/class.egw.inc.php. egw_minimal class should come before egw class.
after that, login screen appears in my installation.

Debian PHP 5.4.27 vs Ubuntu PHP 5.4.16

Well, I'm transferring a little web server from one computer to other, on the 'other' computer I cannot a more updated version of PHP,
I just have to add my files through ssh and that's all, when I load my webpage it says explicitly:
The error is showing on a Debian with PHP 5.4.27 squeeze, the webserver comes from an Ubuntu with PHP 5.4.16 oneiric
Parse error: syntax error, unexpected '[' in ~directory~ on line 38
This is the line 38.
$VALUE=$DB->query("a nice sentence")->fetch()[0];
So, i was pretty surprised because PDO was accepted since PHP 5.1, so, i look deeper and i found the possible error, you can't simply do ->fetch()[0], you must separate it in order to be "processed",
However, I have transport this server with this information before, so i really don't know if it's something on the configuration of PHP or maybe the version by itself 5.4.X? You guys know any hint? As I said, i can't just install other updated version of PHP5, what do you recommend?
Have a nice night.
Edit: updated to the issue on the PHP 5.4 now
The error seems triggered by the array dereferencing. This was added in PHP 5.4.. Not sure how you made that work in 5.3.6
http://nl3.php.net/language.types.array.php
To workaround you could try
$VALUE = $DB->query("a nice sentence")->fetch();
echo $VALUE[0];
PHP Version on my ubuntu (where it works):
PHP Version 5.4.16
PHP Version on the Debian (where it does not work):
PHP Version 5.4.27-1~dotdeb.0
This version number was extracted by using phpinfo(); on the index page.
Apparently, the error was solved by JUST changing the first issue line (the other hundreds of codes that had that wasn't necessary to change, what i believe to be a little weird).
$VALUE = $DB->query("a nice sentence")->fetch()->offset(0);

Zend Interfering with my function definitions. How do uninstall from wamp?

I've installed WAMP Server on my computer so that I can develop my website, however I have come to run my existing code which is running on my staging host just fine without any errors.
I'm getting errors such as:
Fatal error: Cannot redeclare session_status() in >C:\wamp\www\uquiz\trunk\sessions\session.php on line 277
I have uncommented the line in the PHP config:
;zend_extension = "c:/wamp/bin/php/php5.4.3/zend_ext/php_xdebug-2.2.0-5.4-vc9-x86_64.dll"
But this hasn't suppressed the error.
I'm assuming that it's the ZEND Framework that may have already declared the function session_status()?
If I change the name of the function, the error disappears, but I don't want to be restricted.
It's a built-in PHP function as of 5.4.
Rename your function or downgrade to PHP 5.3
http://us.php.net/session-status

Categories