Home >Backend Development >PHP Tutorial >13 Steps to Get eZ Publish 5.x to Work on Homestead
This article was initially going to be a quick tip on how to install eZ Publish on Homestead in just a few steps. However, after I saw how much effort it took to get it up and working from scratch on a Vagrant box hosted on Windows, I decided to make it into a full article. I suffered, so you don’t have to :)
I’m hoping the eZ team will address the issues I state below, and as they do (if they do) I will alter this post accordingly. Granted, my environment is very specific: Vagrant on Windows. However, this shouldn’t matter. Every CMS, app, and framework I’ve tried to boot up in the same way was runnable in a matter of minutes. There is no reason in today’s modern web world for this not to work the same way on everything.
Let’s define the purpose of Vagrant. The purpose of Vagrant is team unity, and production / development parity regardless of host operating system. In other words, the purpose of Vagrant is twofold:
Therefore, we use Vagrant to have identical copies of VMs dedicated to a single project, which can be easily destroyed and rebuilt without repercussions for easier, faster and more scalable development, experimentation and deployment.
Through experimentation with the installation procedures below, I’ve found that eZ Publish does not make this easy. In 2014, most professional developers with multiple clients and/or projects use Vagrant even while soloing – having dedicated, separate, destructible and rebuildable environments for each project is priceless when considering the plethora of hosting options, tools, and versions of those tools at our disposal.
I’m disappointed to not see more apps adopt a Vagrant-first approach these days. Just like we need to think mobile first when developing front ends, we should think VM-first when developing back end libraries, frameworks and apps – otherwise the whole Docker / Vagrant compartmentalization story the world is focusing on is moot, and the apps that fail to adapt will be left behind as the world moves to Heroku, GAE, Amazon and others.
Let’s start the installation procedure now.
Important Note: If you’re not on Windows, Step 5 probably won’t happen to you. If you are on Windows, you can avoid Step 5 by running the entire procedure in an “elevated” Gitbash / command prompt (by running either as Administrator). Admin users are the only ones who have permission to create symlinks on Windows 8. There were rumors of this being fixable, but none of them reliably work. Running your dev environment as Admin opens a whole new can of worms, so do that at your own risk. If anyone successfully gives a regular Windows 8 user permission to create symlinks through Gitbash, please let me know.
Have a Laravel Homestead Improved box prepared and working. If you did vagrant up to see if it works, do vagrant destroy so we can configure it.
Open the Homestead.yaml file, and add a new site:
<span> - map: ez.app </span><span> to: /home/vagrant/Code/ezpub/web</span>
Add ez.app to your host machine’s hosts file, as described in the Laravel Homestead Improved quick tip. Basically, make sure your hosts file contains 127.0.0.1 ez.app. Naturally, also map the shared folder.
Boot the VM with vagrant up and enter the VM with vagrant ssh.
The project needs PHP to have the php-intl and php-xsl extensions installed. It will also ask you for sendmail throughout the setup wizard. In Homestead, you can install all of these with:
<span>sudo apt-get update </span><span>sudo apt-get install php5-intl php5-xsl sendmail</span>
<span>cd Code </span><span>composer create-project ezsystems/ezpublish-community ezpub</span>
The above will create an eZ project for use, not for development. To get the development version, refer to their Github page.
Note that eZ Publish is ridiculously large, and will take a while to do this. It is almost guaranteed you’ll be hitting the “60 requests per hour” unauthenticated GitHub API rate limit, so you might have to input your username and password during the installation process to get through that barrier.
The process might fail a couple of times due to timeouts and the enormous amount of data that needs downloading. If that happens, just remove the entire ezpub folder with rm -rf ezpub and re-run the above create-project command – it will be faster every time, because each time a package is downloaded, it is served from local cache on subsequent requests, rather than being re-downloaded.
The installer will ask you for some data near the end (secret, fallback locale, etc). Fill it out or just hit enter on each to use defaults.
The reason why we’re not using a prepared tar archive downloaded from eZ Publish’s website is because the prepared archive is packed with symlinks – and those don’t work if your VM is hosted on a Windows machine. In an effort to keep things multi-platform friendly, I’ve opted for the composer create-project approach.
As it stands, eZ Publish isn’t really fine tuned for VMs or edge cases and there’s a lot the team didn’t consider – for example, running it in a VM on a Windows box. With all the dependencies, it’s guaranteed to break somewhere during installation. For me, and probably for you too, this will be the post install scripts that install Assets. Install assets is actually part of Symfony which, in the class which does it, does actually warn against Windows and symlinks, but doesn’t take it into consideration if the parent project forces symlinks, like eZ Publish does.
If this happens (you’ll get an error about symlinks and some such), open composer.json and delete the line:
<span> - map: ez.app </span><span> to: /home/vagrant/Code/ezpub/web</span>
This will force the installer to copy the design assets rather than symlink them.
Then, re-run the post-install scripts by executing:
<span>sudo apt-get update </span><span>sudo apt-get install php5-intl php5-xsl sendmail</span>
You might still get an error about the legacy eZ version and a comments bundle of some sort, but I’m not sure how to fix that yet, or whether or not it matters.
Create a database we’ll feed to eZ later on. Log into your MySQL instance in the VM with mysql -u homestead -psecret. Then, run:
<span>cd Code </span><span>composer create-project ezsystems/ezpublish-community ezpub</span>
This step can be skipped on Homestead, because the server already runs under the “vagrant” user, which owns all the subfolders in the ezpub folders.
Edit: see Jerome’s comment below for an approach that handles a part of Step 8 and Step 9 automatically.
Visit ez.app:8000 and see the following screen.
This is where it gets super weird. For no reason, this happens. Yes, it’s a problem that has remained unfixed for two years now – seriously, it’s a two year old unresolved bug in a PHP project. Fixing it in the core would take seven seconds of work, including commit and push (see 8.2). There are two ways to get around it in our case. None is pleasant, so it’s up to you to pick one.
In order to get around it, and I’m dead serious, this is not a joke – you need to open up dev tools, and put ezsetup at the end of the form’s action attribute, because by default it only says index.php. It’s baffling how such an issue can still exist in 2014, but here we are:
Pick this approach if you don’t like altering a framework’s source files.
The second, perhaps slightly simpler approach is modifying the form of the wizard itself, and altering its action attribute.
Go into ezpubezpublish_legacykernelsetupezsetup.php, and find the line:
<span> - map: ez.app </span><span> to: /home/vagrant/Code/ezpub/web</span>
Above it, put this:
<span>sudo apt-get update </span><span>sudo apt-get install php5-intl php5-xsl sendmail</span>
After this, the action attribute will be fixed.
I do not recommend you try to manually set up eZ Publish by skipping the wizard because you will go insane. Objectively, their installation procedure and their documentation are some of the worst I’ve ever seen. You will lose all desire to even try it out if you attempt to follow their instructions. I hope the eZ team will soon completely remove all dependencies and references to their legacy system, leaving in place only the new core – I also hope they’ll soon update their documentation to something more readable and more 2014-like: people develop on dedicated VMs more and more now, and a short installation procedure along with ease of entry are the most crucial attributes of any CMS that wants to stand out.
The eZ Publish setup is out of date enough to know only of one server (Apache) and as such thinks it isn’t running in Vhost mode:
Ignore this warning. Continue on to the next screen (if you used 8.1., don’t forget to alter the form action again, else you’ll start over).
At the end of the setup wizard, you’ll get an Nginx timeout error. This is because eZ Publish is notoriously slow due to it having to process both the awful legacy version and the new version, and due to running on a VM, so when that happens, just remove anything to do with ezsetup from the URL and refresh. You will then be greeted by this beauty:
The error in the above screen happens while eZ is trying to create caches of PHP files, like this one: /home/vagrant/Code/ezpub/ezpublish/cache/prod/stash/0fea6a13c52b4d47/25368f24b045ca84/a1e4f174919d040af6d06113d677c9e0/4a1c6be177996f9e/03934ae1c1c02ffc/9a0364b9e99bb480/dd25e1f0284c8555/caf9b6b99962bf5c/2264824231d7a40c/d3d9446802a44259/755d38e6d163e820.php (ugh, don’t ask…).
This cache engine isn’t clever enough to disable itself in case it fails, so we have to do it manually.
In ezpubezpublishconfigezpublish.yml change the stash block to this:
<span> - map: ez.app </span><span> to: /home/vagrant/Code/ezpub/web</span>
“In memory” means the memory will be used for stash cache, instead of the File System. Clear the cache with rm -rf ezpublish/cache/* and refresh. If need be, replace the cache engine with something more decent than FileSystem cache later on. I have no idea how else to alleviate the protocol error for mkdir – I know it’s VM-related, but not much more. Any advice is much appreciated.
You will now likely be greeted by yet another flurry of warnings and a 503 error at the end:
But at least we got the title to render!
The file causing all these warnings is, in fact, a compilation of all the required PHP files for eZ to load up. They’ve been merged into one (!!!) and put into the ezpublish folder, from whence it is served. The file is a mess of code and not easy to debug because, apart from not having the php extension and lacking IDE highlights, it also doesn’t respect any kind of coding standard (hence, dozens of classes in one file, no indentation and with that, no readability), it being “just a cache file”, after all. But when your entire application depends on a cache file, it would be nice to be able to debug it easily.
Horrible caching practices aside, we can disable this entire mess and just load up eZ Publish in debug mode by changing the ENVIRONMENT environment variable. You can change this in Homestead.yaml so it gets autoconfigured during boot by adding it to the “variables” block:
<span>sudo apt-get update </span><span>sudo apt-get install php5-intl php5-xsl sendmail</span>
Or, you can just edit the index.php file under ezpub/web and put $environment = 'dev'; under $environment = getenv( "ENVIRONMENT" ); on line 8.
At this point, the second approach is easier if you’ve followed along, because otherwise you’ll have to start over with the entire setup process if you destroy and up again.
Finishing this, you should be able to get this to render:
Due to eZ Publish request responses being so absurdly large, we need to up Nginx’s limits:
<span>cd Code </span><span>composer create-project ezsystems/ezpublish-community ezpub</span>
Under the root directive, paste the following:
<span>"symfony-assets-install": "relative",</span>
Save, exit, restart Nginx with sudo service nginx restart.
Some pages will work (blog, discover), others, well, not so much. Debugging their Demo bundle, however, is outside the scope of this already too long article.
By default, all Symfony apps have “app.php” or in eZ Publish’s case “index.php” in their URL for some reason. I guess someone has to support those hosting providers and developers from 2001. Let’s bring both projects into the 21st century by removing it.
<span> - map: ez.app </span><span> to: /home/vagrant/Code/ezpub/web</span>
As per instructions here, above the “location” block, add:
<span>sudo apt-get update </span><span>sudo apt-get install php5-intl php5-xsl sendmail</span>
Save, exit, and restart nginx with sudo service nginx restart.
After an arduous process, we’re finally done. What took me more than a day, hopefully took you less than 10 minutes (excluding download times). Now you too can try this powerful, albeit overbloated, overcomplicated and outdated CMS on your own Homestead instance. Let me know how it works out!
Any CMS that requires this much work to get up and running on a Vagrant box is, in my mind, not a CMS worth paying attention to. Sure, you can probably easily install it onto a host machine and run it that way, but that’s not a professional approach – development environments need to be encapsulated and isolated, and developers need to be able to destroy and rebuild an instance on a whim. A CMS should have scripts that auto-execute, detect all possible problems (like Symlinks not being available and switching to hard-copy mode automatically) and set everything up (from the database to the folder permissions, if necessary), only asking for sudo along the way.
This process has installed eZ Publish, but was it worth it? That’s up to you to decide. While eZ definitely is a powerful CMS, the difficulties of getting into it are detrimental at best. You now have a common starting point to test it out on, and I’ll be sure to find out more about these issues from the eZ people at PHP Summer Camp and elsewhere. Until then, let’s get some eZ tutorials going on this box, shall we?
Put your feedback in the comments below, I’m eager to hear different approaches, especially if you’ve tried to do this on a non-Windows host and made the demo bundle work!
Edit: This Github repo has been brought to my attention. It is a prepared vagrant configuration of eZ Publish that works. There are two caveats, though:
EZ Publish 5.x on Homestead offers a range of benefits. It provides a robust and flexible content management system (CMS) that allows you to create, manage, and publish content on your website. It’s also open-source, meaning it’s free to use and can be customized to suit your specific needs. Homestead, on the other hand, is a virtual development environment that simplifies the process of setting up and managing your EZ Publish site. It provides a consistent environment across different machines, reducing potential issues that can arise from differences in local development environments.
EZ Publish 5.x stands out from other CMS platforms due to its flexibility and robustness. It’s designed to handle complex websites and large volumes of content, making it a great choice for businesses and organizations. It also offers multilingual support, which is a key feature for businesses operating in multiple countries. Additionally, its open-source nature allows for extensive customization to meet specific needs.
The installation process for EZ Publish 5.x on Homestead is straightforward, especially if you follow the step-by-step guide provided in the article. It involves setting up Homestead, configuring your system, installing EZ Publish, and setting up your site. While it may seem complex if you’re new to this, the guide breaks down each step in detail, making it easier to follow.
Yes, it’s possible to migrate your existing website to EZ Publish 5.x. However, the process can be complex depending on the current platform your website is on and the amount of content you have. It’s recommended to seek professional help or thoroughly research the process before attempting a migration.
As an open-source platform, EZ Publish 5.x has a large community of users and developers who can provide support. There are also numerous online resources, tutorials, and forums where you can find help. Additionally, professional support services are available from eZ Systems, the company behind EZ Publish.
EZ Publish 5.x is designed with security in mind. It includes features like role-based permissions, secure password storage, and protection against common web attacks. However, like any software, it’s important to keep it updated and follow best practices for web security to ensure your site remains secure.
Yes, EZ Publish 5.x can be used for e-commerce sites. It supports a range of e-commerce features, including product management, shopping cart functionality, and payment gateway integration. However, you may need to use additional plugins or extensions to provide all the features you need for your e-commerce site.
EZ Publish 5.x requires a web server like Apache or Nginx, PHP 5.4 or higher, and a database like MySQL or PostgreSQL. It also requires certain PHP extensions and settings. Detailed system requirements can be found in the EZ Publish documentation.
There are several ways to optimize the performance of your EZ Publish 5.x site. This includes using caching to reduce server load, optimizing your database, and using a content delivery network (CDN) to speed up content delivery. Regularly updating your software and plugins can also help improve performance.
Yes, EZ Publish 5.x is highly extensible. You can add new features and functionality using plugins and extensions, and you can also customize the core code due to its open-source nature. However, it’s important to note that modifying the core code can make it more difficult to apply updates and could potentially introduce security risks.
The above is the detailed content of 13 Steps to Get eZ Publish 5.x to Work on Homestead. For more information, please follow other related articles on the PHP Chinese website!