I have been given a zend project to work on, when i do the usual composer.phar install/update the existing ZF2 folder is unchanged, a new zend framework folder is created instead.
I ask this question because I updated once after deleting libraries in ZF2 folder and they were reinstalled (in the ZF2 folder).
If this is the current default behavior then all good, but I have a nagging feeling that i might not be updating correctly, and therefore not confident of the project behavior.
Is installing directly into existing ZF2 folder now defunct?
ZF2 version < ~2.5 will download a folder vendor in which will put a new folder called zendframework/zendframework/library/Zend/all zend modules.
In version 2.5+ ZF2 is using a new way of distributing its modules via separated meta packages, which makes it even easier to maintain. Of course the structure is different /vendor/zendframework/all zend modules
If you have any 3rd parties packages for example: phpunit, fabpot, symfony, bjyoungblood etc, they will be stored in your vendor/packagename folder, regardless of your ZF2 version.
However, there are few exceptions for modules like zend developer tools and zendxml, which will be installed in your vendor/zendframework folder.
Related
I've recently inherited a project build on a particular PHP framework, Asgard. The framework itself is less important.
The code is stored on GitHub and contains the framework files, some of them modified, and a few dependencies. Upon installation, one should run composer install, which will bring the rest of the dependencies.
Most of the custom code is in two folders, located in public_html/modules and in framework/Modules, respectively. However, there are some framework files that have been modified.
The code management/installation procedure seems illogical to me, and I would rather all of the framework code (the specified version of it) would be brought by composer and only the few files be applied on top, as a patch.
Is there some development workflow that would allow me to push to GitHub just the changes, not all of the framework files, and then somehow apply a patch over the framework code when composer install runs?
I'm aware that composer is configured via composer.json and composer.lock, I just don't know how to do the patch.
Also, I don't know how to push just the changes to Git, without including the initial framework files, while retaining full functionality in my working folder.
Any idea would be appreciated.
Thanks.
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).
I am going to rewrite this question to be more clear. I have the following application structure:
applications/
api/
public/
composer.json
frontend/
public/
composer.json
backend/
public/
composer.json
common/
vendor/
... composer libraries here
How can I make that every single application's composer install gets installed into common/vendor, so that way I can have the most up to date version of the library in wherever is used with just one composer update; while at the same time only load the libraries that are in the composer.json file of each application. So, when I include vendor/autoload.php, only the needed libraries are loaded.
EDIT: Edited the whole question. Please reread
You have to create one bigger meta project that requires the API package, the frontend and the backend. You can define which directory should be used for placing dependencies for this meta project, and should be able to define for the special packages API, frontend and backend that they should go into their respective directories and not the common folder.
Updating that meta package will have to check more dependencies, but it is guaranteed that you either get the newest possible versions that conform to your version constraints (which may NOT install the newest version available if one of your packages requires a lower version). That way you would avoid installing dependencies that are not allowed for one of the projects, and you would be immediately notified if you attempt to install conflicting versions.
Note that I wouldn't recommend this at all. I would write a script, placing it at applications/updatecomposer.sh and add all the commands necessary to update each project individually. You gain all the flexibility that Composer is about, because essentially you want to have the central library installation of PEAR back. This central installation and the resulting inability to update any of the PEAR packages without risking to break something is one of the reasons that PEAR is considered dead.
Or think about any pre-Composer originating framework like Zend Framework 1. Having this installed in a central point that every application is using will effectively prevent you from ever updating it, if you are not prepared to also deal with incompatibilities in ALL your applications at the same time. Just an example: Updating from any ZF 1.11 to ZF 1.12 (the currently maintained up to date version) is a potentially backwards-incompatible change, because at least one abstract class (dealing with REST interfaces) got new abstract methods that have to be implemented.
This is a basic best practice question.
I started my first project using the Laravel framework. I just recently added the L4withSentry bundle to my laravel project. I followed the setup steps and everything is up and running fine, but I noticed that all of the code that's running for the site is running from the vendor folder of my project even though I published all of the views and assets.
Should I leave all of the code in the vendor folder and customize it there? I'm under the understanding that if I update composer and any of the vendor files need to be updated I'll lose all of my code. Should I move the controllers into my app folder?
packages should stay in the vendor folder. the sentry package makes it actually easy to customize or set your own model outside of sentry, so you don't have to fiddle with vendor packages.
if you really have to change some behaviour in a vendor package, you'd create a new class extending that vendor package's class.
We created a ZF2 project with skeleton app and it works fine for a simple test application. Now we are working on a real project. My question is what we should store in the repository (SVN), the whole project structure or just the new source code? ZF2 comes with a vendor directory which is almost 31MB in size (which has the ZF libraries). Should we store the whole vendor folder in SVN?
This is the first time we are using PHP and ZF so are not clear in how we will deliver the complete project to production from SVN. Also what is the build process if at all exists. Any clues/links to "ZF2 project packaging" is appreciated.
No, don't include dependencies in your repository! Putting your dependencies under version control doesn't do any good, it just blows up your repo for no reason.
You want to add the skeleton to your repository and your own library but definitely not the framework or any other dependencies.
The way to go is to use composer for dependency installation and some kind of build tool like Phing to automate installation of your project.
See the relevant chapter on phptherightway for more information on how to build your application.
The most simple build process doesn't even need a build tool
checkout your project from SVN/git
run php composer.phar install to install the needed dependencies (defined in your composer.json)
But most probably you want to do some more stuff like setup up the environment, deleting some files, etc.
A word about ZF packages. They're not available from packagist but you can install them with composer anyways. You just have to add the dedicated repository to your composer.json as described here: http://framework.zend.com/downloads/composer