I'm working with Zend Server CE on a Windows 7 (64bit) System.
I'm developing a website with Zend Framework 2.0. In this website I use DOMDocument to analyse an external website (given by URL).
I started this project with Zend Framework 1.12 and Zend Server CE 4 (PHP 5.2). Now I installed the Zend Server CE 5.6.0 (apache2.2, PHP 5.3.14, ZF2-Support). I rebuild my project with ZF2.0. Everything works fine...except one function.
I get this Error-Message (php-error.log), when I try to instantiate DOMDocument:
Fatal error: Class 'Application\Controller\DOMDocument' not found in
_Path_\module\Application\src\Application\Controller\SearchbarController.php on line 81
With PHP 5.2 (ZF 1.12) and Zend Server CE 4, this function worked perfectly. But now...without any change, it throws this error.
The dom-extension and the xml-extension are built-in in PHP 5.3. I checked phpinfo and my php.ini, that these extensions are running.
I read, that i should install php-xml. But dom, xml and libxml are running...why should i re-install them?
I don't know, why DOMDocument could not be instantiated after upgrading the Zend Server CE. May be, that the ZF2.0 is a possible reason for this error. But I can't find anything pointing to this.
In short, it's introduction of namespaces (feature of PHP 5.3 quite heavily used by ZF2 - but not ZF 1.x) that caused this bug. With this line...
$dom = new DOMDocument(...)
... only the currently imported namespace is checked for this class by ZF. And it results in failure, because DOMDocument class actually belongs to the global namespace.
The solution is simple, when you see the reason: use the global namespace specifier - \ symbol - in front of the class name. Like this:
$dom = new \DOMDocument(...)
Related
Using Laradock (basically a set og Docker images for Laravel development), I keep getting Class 'MongoId' not found FatalThrowableError errors when calling new \MongoId( $id ) in PHP.
This post Class 'MongoId' not found (Zend Framework with MongoDB Doctrine) suggests that the reason for given error is that the PHP Mongo extension isn't enabled.
However, if I look at the phpinfo() output, I can see mongodb section. Doesn't that mean it's enabled?
What else could possibly cause this error?
I assume that you are using php 7 version.
In php 7 version a new MongoDB extension is used.
So instead of legacy MongoId you should use MongoDB\BSON\ObjectID
I have an error while running my website which coded with PHP and uses zend optimiser on hostmonster shared hosting.
The issue appeared since I updated from PHP 5.2 to PHP 5.4.
Now when I try to use 5.2 the error is
"Zend Optimizer" is not installed on the Web Server and therefore cannot service encoded files
On PHP 5.4 the error is
Fatal error: Incompatible file format: The encoded file has format major ID 65535, whereas the Loader expects 5 in /home1/mylingui/public_html/admin/config/ProjectConfig.php on line 0
php.ini
zend_loader.disable_licensing=0
zend_extension=/usr/php/54/usr/lib64/php/modules/ioncube_loader_lin.so
zend_extension=/usr/php/54/usr/lib64/php/modules/ZendGuardLoader.so
From what I was able to figure out from the Zend forums, your file is encoded for the PHP 5.2 version of Zend Encoder. You need to ask your vendor for a version encoded for PHP 5.4
(http://forums.zend.com/viewtopic.php?f=57&t=112658)
HTH,
=C=
Manager of Training for Zend
I'm trying to install zend-escaper but I'm getting this error:
This is strange as my PHP version (from phpinfo()) is 5.5.19, the message claims it is 5.3.5(!) which should satisfy the requirement anyway.
My ZF version is 1.12.13
I'm using PHP Storm
Can anyone help please?
Thanks
Tomasz
The PHP version on the command line can be a different executable than the PHP running inside the web server. It also can use a different pho.ini configuration file.
So if Composer states the PHP it is using is 5.3.5, this is correct because Composer is directly asking the PHP it is running on for its version. The problem is when this PHP version on the command line is way older then the PHP version in the web server.
Try to update your command line PHP.
Some more things to say: the version 5.3.5 is lower than the required 5.3.23, because the last number in the version is 5 compared with 23, and 5 is less than 23. So the version you are using is below the minimum requirement for zend escaper - at least in the version 2.5.1 you try to use. Such an old PHP was last supported in the 2.2 framework versions, so you might as well try to depend on ~2.2. However this will simply be a workaround for the old cli version.
One other note: You are in the process of installing a zend framework 2 component - don't expect your installed zend framework 1 to support any fancy stuff on its own. It is possible to mix classes with namespaces and without, and even use zf2 things together with zf1, but zf1 won't offer any automatic functionality to use these.
I am using the Zend Autoloader to load Zend classes for integrating Zend_AMF with my application. Everything was working perfectly until I installed APC 3.1.9 and enabled it.
I am getting this error:
Fatal error: Access to undeclared static property: Zend_Loader_Autoloader::$_instance in C:\blahblah
I am assuming that APC seems to have trouble with autoloaders and static properties and static methods.
APC is version 3.1.9 and is installed on a Windows 7 machine with PHP 5.3.8 running as fastCGI on an Apache 2.2 server.
Has anyone seen this error before? If so, what are some ways to fix this?
Looks like it was actually not the fault of the autoloader. APC sometimes does not play nice if you have a custom session handler.
The trick is to add this to the earliest part of your script (the first include if possible): register_shutdown_function('session_write_close');
This will tell PHP to finish writing and close (not destroy!) the session when the script finishes executing or is terminated (using exit() etc).
I am using 'MJS_Controller_PathRouter' in any ancient Zend Framework version 0.6 and PHP 5.1.6. When I run this in a newer php version e.g. 5.2.x or 5.3.x, it is throwing this error:
Declaration of
MJS_Controller_Router_PathRoute::__construct()
must be compatible with that of
Zend_Controller_Router_Route_Interface::__construct() in
/opt/ezxwebadmin-versions/ezxwebadmin_2.11.5/Library/MJS/Controller/Router/PathRoute.php
on line 34
I would like to remove this enhanced rewrite router and upgrade our application to use a newer Zend Framework version. Our web application doesn't use any of the classes provided by Zend and we are only utilizing the MVC architecture and rewrite functionality from Zend framework.
Now could any one advise which Zend Framework version would be best for us to upgrade to?
The error you are getting is actually a PHP strict coding standards error and should be fairly easy to fix. Just open up Zend_Controller_Router_Route_Interface and MJS_Controller_Router_PathRoute and compare the parameters for the __construct method. They need to be the same, so change your class to match the parameters in the interface.
Zend Framework requires PHP 5.2.4. ZF2 will require PHP 5.3+. PHP 5.1.6 is almost 5 years old so you really should be upgrading (or planning to). If you are using something like CentOS with really ancient PHP packages, you might want to consider switching to Zend Server community edition (which is free). This can be installed with Yum and will give you more recent versions of PHP.
You should take a close look at the Zend Framework Migration Notes starting at 0.8
Then look through the Zend Framework Download Archives and upgrade your framework version by version (follow the versions listed in the migration notes) to either get to a version that works with the PHP you have or (ideally) the latest version: 1.11.x