Rector: Zend 1 to Symfony 5 (2019)

Created on 11 Apr 2019  路  12Comments  路  Source: rectorphp/rector

Much needed set

Most helpful comment

I started testing ZendToSymfony set today.
Here are my observations that don't deserve to be raised as issues.

  1. Autoloading

At first rector was failing with errors like this:

 [ERROR] Could not process "application/controllers/ScheduleController.php" file, due to:
         "Analyze error: "Class Form_Abstract not found and could not be autoloaded.". Include your files in "parameters  > autoload_paths".
         See https://github.com/rectorphp/rector#extra-autoloading".

Adding more directories to "parameters > autoload_paths" didn't help.
I solved this issue, by creating autoload.php file and including it with --autoload-file=autoload.php

set_include_path(get_include_path() . ":/srv/share/sites/lib/");//parent of Zend directory
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
  1. $this->getRequest() should be processed in the same way as $this->_request.

All 12 comments

Notes from PHP Day 2019 in Verona

Yay, I'm glad I've found this thread. I will have to move one project from Zend 2 to Symfony 4. @TomasVotruba it is a bit easier than from Zend 1, isn't it?

Not sure there is much difference, but this set will take more work. And also lot of custom work for the project. I feel confident that it's still cheaper and faster than doing it manually in almost any case.

We're now looking for a company that needs this migration as a paid service - see https://www.patreon.com/posts/are-you-on-zend-26564268

First 7 migration rules are here :tada:

https://github.com/rectorphp/rector/pull/1980

I want to create a rector to remove Zend_Json from our project. Would this also match to ZendToSymfony package? Cause the replacement would be a json_encode :sweat_smile:

I think you've got a match :wink: I look forward to the PR

I started testing ZendToSymfony set today.
Here are my observations that don't deserve to be raised as issues.

  1. Autoloading

At first rector was failing with errors like this:

 [ERROR] Could not process "application/controllers/ScheduleController.php" file, due to:
         "Analyze error: "Class Form_Abstract not found and could not be autoloaded.". Include your files in "parameters  > autoload_paths".
         See https://github.com/rectorphp/rector#extra-autoloading".

Adding more directories to "parameters > autoload_paths" didn't help.
I solved this issue, by creating autoload.php file and including it with --autoload-file=autoload.php

set_include_path(get_include_path() . ":/srv/share/sites/lib/");//parent of Zend directory
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
  1. $this->getRequest() should be processed in the same way as $this->_request.

Closing as sponsor is stale.

If you're company looking for this kind of migration, let me know

I may get back to this Rector in a few years time when the company I work for is ready to upgrade its legacy projects to PHP 7.

However, converting controllers is an easy part, most of our projects use Zend_Config, Zend_Db and Zend_Http_Client heavily and, I think, there is no way to convert that code automatically.

Just let me know when you're ready.
In my experience, anything PHP 5.3+ and MVC and object is easy to convert.

Was this page helpful?
0 / 5 - 0 ratings