Upgrading Zend Framework - Steps & Guidance - php

The site I maintain is currently using Zend Framework 1.8.0, which is over 2 years old. I'd like to upgrade to 1.11.11 and am having some trouble finding basic guidelines for how to pull this off smoothly. Is it as simple as overwriting the library/Zend folder with the latest files?
Here are my steps I plan on taking. Am I missing anything?
Download latest Zend Framework code.
SSH into the server and copy library/Zend to /path/to/webapp/library and call the folder something like Zend-1.11.
Put up "Site is down for maintenance page" on our site.
cd /path/to/webapp and then make a backup copy of current Zend version, e.g. cp -R Zend Zend-old
mv Zend-1.11 Zend
Remove "Site is down for maintenance page"
At this point, the /library/Zend folder would have the latest Zend Framework code and I'd have "Zend-old" to switch back to in case anything goes wrong.
Is this the typical way to upgrade?

Things to do before updating Zend Framework:
Read the change log from your current version to the latest version that you are downloading.
While doing so, make sure all your current code will work without any bugs, even minor. Usually all updates are backward compatible. (But sometimes, if there are any major changes around a particular module, you will have a little rework in your code)
If the new version of ZF has a new feature that you can use for your site, modify your site to use it.
Update the framework in your development environment first (by pointing your lib path to the new framework files) and then make sure all parts of your site works the same and all your tests are passing.
Then update your production site with the new version using the same way mentioned in the question.

I went through a much more extreme upgrade going from Zend 0.70 to 1.11 a few months back. What I did was qualify the new library folder with a version number and use the application.ini setting to switch between the 2 for testing.
so
includePaths.library = APPLICATION_PATH "/../library"
would become
includePaths.library = APPLICATION_PATH "/../library1.11"
I found having both entries and just moving a comment was a lot faster for testing. Good luck with your upgrade!

You might also take a look at the ZF-tool.
It is not only the Zend lib that might be replaced with a newer version.
If you replace the Zend lib you beteer type things like zf show version.

Related

Zend Framework 2.5 installation process + Nginx + Ubuntu 14.04

I'm trying to install Zend on my ubuntu 14.04 + Nginx.
1) I have downloaded zend via composer
composer require zendframework/zendframework 2.5.0
2) Tell php location of zendframework via include_path. Something like that
include_path = ".:/usr/share/php:/home/dmitriy/zend/vendor/zendframework"
Folder looks like:
Zendframework folder
At this step, I thought that everything is almost done, and i need to download skeleton application to launch index.php.
3) I downloaded zip form Zend Github Repository. Extracted it.
Created nginx entry point to /public/index.php.
What I get at finish:
Page w/o images,css, etc.
Console:Console with wrong paths
Links are not reachable...
Can someone tell me:
1) Is step No:2 required?
2) Why links are broken?
3) Zend(1.11) library have another structure, maybe it is problem here and I have download wrong files?
Or give me links for ubuntu+nginx guide, i could not find.
Thank you.
You seem to be trying to install ZF2 rather than ZF1, so you can drop all the old bad practices such as modifying the include path to include a library.
Please have a look at the official tutorials to get started: https://docs.zendframework.com/tutorials/
Short version: you can download a "skeleton" rather than the librar(y|ies). A skeleton is a fully configured Zend Framework MVC project, you can then tweak it to suit your needs.
On another note, most php projects do not use the include path to autoload libraries for a few years now, and use Composer and the PSR-0 and PSR-4 recommandations. As you only seem to get started, I'd recommand you read a bit on PSRs, and then follow a ZF3 or Zend Expressive tutorial to get started, and not bother learning a legacy framework (even though ZF2 and ZF3 are really similar).

Any Step By Step Guides to Updating Smarty PHP Framework?

Trying to fathom out how to update smarty php framework from 3.11 to current 3.21
Can anyone suggest where to find a detailed guide for a dummy or list step by step here?
Ive searched just about everywhere.
Yes i understand 3.22 arrives shortly (2 weeks) and will come as standard set for HHVM this being why i want to resolve any issues now in the current update before tackling any when 3.22 arrives.
Thanks
Updating Smarty from version 3.xx to 3.yy is usually not very difficult, its nothing like the big upgrade from 2.xx (but they've written a guide for that....). Just replace your Smarty installation directory with the one from of the newer installation.
Just for safety reasons, I usually do it like this in my development enviroments.
Directory structure:
./Smarty/ <- Symlink to ./Smarty-3.1.12/
./Smarty-3.1.12/
./Smarty-3.1.13/
Your php-scripts include Smarty like this:
require('./Smarty/libs/Smarty.class.php');
For an update just copy the newer version into a new folder and change the symlink to show to the new folder.
rm Smarty
ln -s Smarty-3.1.13 Smarty
If you run into issues, just switch the symlink back to the old installation until solving the issues.
You might have to empty your /templates_c/-directory, too, in some cases.

How do I successfully create a project with Zend Framework and PHPUnit?

Let me just start by saying that I've posted this to multiple forums and even tried to get help on the ZF IRC channel. I've been Googling for a straight week and still no results. I've read a lot of Q's and A's on this site in the past, so I figured I'd make an account and try asking you.
(Yes, I've searched previously asked questions, but none of the answers helped me.)
I'm trying to learn how to use Zend Framework for a new project that I've joined. For compatibility reasons they are using Zend 1 (and not the newer Zend 2). I have found and followed a number of online and physical book tutorials but I've the same results over and over again.
So here goes (this are the instructions that all the tutorials give). I went to framework.zend.com and downloaded the full version of ZF 1.12.
I unzipped the contents
I moved the library folder to a safe directory where it won't be modified
I moved the contents of the bin folder to same directory as my PHP executable
I changed the include_path in my php.ini file to include the library directory
I updated my Windows PATH variable to make sure it included the path to the PHP executable
I ran
zf --help
This command worked as intended. I also successfully ran zf show version (Zend Framework Version 1.12.7).
I ran the command
zf create project myproject
Upon doing this, I receiving the following error message:
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in D:\Zend\library\Zend\Test\PHPUnit\ControllerTestCase.php on line 48
That particular line in question is a class declaration that extends PHPUnit_Framework_TestCase. I don't know where PHPUnit_Framework_TestCase is defined. It is not in any of the files or directories that came in the single ZIP file that I downloaded from Zend. I even ran grep on all files and folders searching for the string "class PHPUnit_Framework_TestCase" but it printed no results.
Some have suggested that I don't have PHPUnit installed (which is obvious to me now). The part that bugs me is that absolutely none of the tutorials that I read mention anything about installing PHPUnit before hand or how to install it or what dependencies Zend has on it. Many of these were beginner tutorials that assumed you only had a basic knowledge of PHP, and it's pretty shocking to me that none even mentioned PHPUnit. If PHPUnit was that important I would think that the file I downloaded from Zend would have included it. I guess not.
So I went online again and got the PHAR file for PHPUnit, but now what? I tried putting it in multiple different directories but I still get the same error. Am I not supposed to use a PHAR file? Should I be using the actual files instead?
What do I have to do to get ZF to recognize PHPUnit, resolve this error and create my first ZF project?
Additional Info:
Windows 7, XAMPP Server (running on localhost), PHP 5.5.6
Assuming you have PHPUnit installed and it is on your include path (Bearing in mind that ZF1 only officially supports PHPUnit 3.4.x and definitely doesn't support anything above PHPUnit 3.5.x, so if you're using XAMPP you may have to downgrade PHPUnit as described here). The problem is most probably due to this commit, where the require calls for PHPUnit were stripped out in favour of using an autoloader. The ZF tool over CLI doesn't set up an autoloader though, so PHPUnit is not found because it is simply not required! To fix you can return these lines to the start of Zend/Test/PHPUnit/ControllerTestCase.php
/** #see PHPUnit_Runner_Version */
require_once 'PHPUnit/Runner/Version.php';
/**
* Depending on version, include the proper PHPUnit support
* #see PHPUnit_Autoload
*/
require_once (version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '>=')) ? 'PHPUnit/Autoload.php' : 'PHPUnit/Framework.php';
It's worth noting that even with the error you mention, ZF tool should still work correctly when setting up a project, it just won't produce unit test actions (you'll have to make them yourself). If you don't want to downgrade your XAMPP PHPUnit version you should be able to add the correct version locally to your project using composer as described here.
Update Jan 2015:
Downgrading PHPUnit for XAMPP is no longer necessary as ZF1 has supported at least version 4.1 of PHPUnit since 1.12.7 (I've not tested above 4.1). This is helpful as PHPUnit has completely removed their deprecated Pear repository as of December 2014, which means you can't download versions older than 3.7 anymore anyway! (Currently XAMPP ships with PHPUnit 3.6). These days though it's probably worth chucking XAMPP for Vagrant and globally installing PHPUnit 4.1 via Composer during Vagrant provisioning.
I recommend using Composer to load both ZF and PHPUnit. Then make sure to include the Composer autoload.php file as your/in your phpunit boostrap file.
I had the same problem when I set up my laptop as a second development machine and downloaded the newest version of Zend Framework 1 (1.12.9). Whenever I tried to create a new action in a controller, I got the same error. Yet on my main computer, it worked fine.
I realized it was because the version of ZF1 I had in my php includes path was actually 1.11.11. So I went and got 1.11.14 from the ZF archives page, put it in the includes directory, and it worked fine.
Not entirely sure if this is the best way to make it work, since it is an older version, but at least it does work. And until someone actually comes on here and offers a better solution, that's what I intend to stick with.
You can create or edit a .zf.ini file in your home directory (~/.zf.ini or C:\Users\YOUR_ACCOUNT\.zf.ini on Windows)
php.include_path = "PATH_TO_THE_LIBRARY_FOLDERS_CONTAINING_ZEND_AND_PHPUnit"
basicloader.classes.0 = "PHPUnit_Framework_SelfDescribing"
basicloader.classes.1 = "PHPUnit_Framework_Test"
basicloader.classes.2 = "PHPUnit_Framework_Assert"
basicloader.classes.3 = "PHPUnit_Framework_TestCase"
If you are using Netbeans on Windows it could looks like this (you can put several library folder, just separate them with a semicolon ;) :
php.include_path = "C:\Users\romain\dev\ZendFramework-1.12.17\library;C:\Program Files\NetBeans 8.1\php\zend;C:\xampp\php\pear"
basicloader.classes.0 = "NetBeansCommandsProvider"
basicloader.classes.1 = "PHPUnit_Framework_SelfDescribing"
basicloader.classes.2 = "PHPUnit_Framework_Test"
basicloader.classes.3 = "PHPUnit_Framework_Assert"
basicloader.classes.4 = "PHPUnit_Framework_TestCase"

Cannot browse Zend Framework project "Class 'Zend\Filter\AbstractFilter' not found "

I'm new to Zend, and i'm trying to create my first zend application. I'm following the tutorial here. http://akrabat.com/zend-auth-tutorial/
Unfortunately, i'm using xampp. I found that it arises some conflictions when using xampp with zend.
i have added
C:\xampp\php
to my system variables and I edited include_path in php.ini file to
.;C:\xampp\php\PEAR;C:\xampp\htdocs\zend\library
But when i'm trying to view my newly created project, it outputs this error.
Fatal error: Class 'Zend\Filter\AbstractFilter' not found in C:\xampp\htdocs\zf-tutorial\library\Zend\Filter\Inflector.php on line 19
I have no idea since i'm new to Zend. Please help me out guys...
I just found this question because I was having the very same problem, hopefully it will be useful in the future, sorry for resurrecting a fairly dead post.
For me, this problem was because I downloaded zend framework 2, and added that Library to my include path in PHP. However it turned out that my OS (A linux distro called crunchbang) comes with zend framework 1.1 pre-installed.
My autoloader was loading basically everything from the 1.1 library, and when it didn't find it, it fell back to the 2.2 library, it found the Inflector in 2.2 but for whatever reason, didn't find the AbstractFilter that was right next to it.
I figured this out by adding a register_shutdown_function that blurted out all the included files, using get_included_files().
Once I had figured out the problem, it was an easy enough fix, I removed the zend framework 2.2 include from my PHP config, and presto, everything was golden :)
Regards,
Phil,

How can I get a Zend Framework project to run on IIS?

I am trying to get the Zend Framework (ver 9 Studio) to deploy and actually run on my local IIS server.
I have created a very simple little app using the built-in wizard. It works fine if I run it on the Apache server that comes with Zend. But I tried to copy the files over and run it on IIS, and I get errors.
It appears that it is missing the links to the libraries. I've tried manually isolating and grabbing the missing libraries and putting them into the /library folder. This is a good start but I still get other errors down the road.
I found a tutorial out there that comes with an example of a Zend Project that runs in IIS. But, it pretty much has the same problems as the project I created. More missing libraries. The tutorial includes some neat new tricks like a web.config that is supposed to replace the need for the .htaccess that Apache uses.
That's how far I've made it. This is all very frustrating. Does anyone have a simple example like that tutorial promised? If not, just some good information would be helpful.
you need the rewrite module, Rob Allen has a little tutorial to help. The biggest problem is usually the rewrite module, because you have to install it seperately.

Categories