Zend Framework Composer Packages - php

I would like to add dependency to zendframework/zend-db package, so I added it to my composer.json:
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
}
],
"require": {
"php": ">=5.3.2",
"symfony/class-loader": "dev-master",
"symfony/console": "dev-master",
"symfony/filesystem": "dev-master",
"symfony/finder": "dev-master",
"symfony/locale": "dev-master",
"symfony/yaml": "dev-master",
"doctrine/dbal": "dev-master",
"zendframework/zend-db": "dev-master"
}
The problem is that composer installs entire zendframework/zendframework package.
Any idea why?

as explained here http://packages.zendframework.com/#composer ZF2 now provide a composer repository with all modules.
to add the repo to you package:
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
}
],
and from here on you can add packages seperately:
"require": {
"zendframework/zend-config": "2.0.*",
"zendframework/zend-http": "2.0.*"
},
you only need to specify the packages you want, if they have dependencies they will be resolved by compser.
allthough this does not seem to work atm...

Here's the composer.json from zend-db in the zend github. According to the file, zend-db does not have any dependencies.
This can be due to the fact that you're trying to download a package from dev-master and there's a missmatch in the composer.json of the dev-master.
I would suggest you to change the required version to something like 2.0.* and try again.
Also, Although Zend Framework is loosely coupled, in the older versions of the framework the dependencies were not explicit.
For instance, with a quick sweep over the source code of zend_db from ZEND 1.9, I found that it depends, at least, on the following packages:
Controller
Config
Filter
Json
Loader (for autoloading, I reckon this might not be necessary due to composer autoloader)
Uri
View
Wildfire
These packages might have other dependencies, hence the download size. Regardless, as King explained, Zend Framework 2.0 is different from version 1.9 and maybe this is not applicable to 2.0

Try to check if some packages have some php extensions in their dependencies. I have tried to install zend-http packages and have the same issue. Here I've found suggestion to install php_intl extension because it is required by zend-validate - subdependancy of the zend-http package. Once I've added this extension to the php.ini - problem was solved.

Related

composer - update cakephp app

I have a cakephp app with following in the composer.json
"require": {
"php": ">=5.4.16",
"cakephp/cakephp": "~3.0",
...
},
If I update it using: composer require cakephp/cakephp:"~3.3", I get:
"require": {
"php": ">=5.4.16",
"cakephp/cakephp": "~3.3",
...
},
however, cakephp v3.3 requires php version 5.5.9, so I wonder what composer command should I use to update json file to the following
"require": {
"php": ">=5.5.9",
"cakephp/cakephp": "~3.3",
...
},
The whole point of a dependency manager is so you don't have to worry about dependency trees yourself.
Since you depend on cakephp/cakephp ~3.3, and it depends on php >=5.5.9, your application implicitly depends on that same version.
This doesn't conflict with your current dependency on php >=5.4.16, but you can probably remove your PHP dependency entirely.

composer custom repository package can't pull dependency

Running into an issue with composer. I have a main project that im working on with some some small libraries I built that I want to more easily share between my projects. They are nowhere near release ready, so I do't want to add them to packagist, but when I require 1 that requires another, it will error unless I ad that custom repository as well on my master composer.json
also, the tertiary requirement can not resolve packagist libraries
Your requirements could not be resolved to an installable set of packages.
Problem 1
- ethereal/simpleCache dev-master requires predis/predis ^1.1#dev -> no matching package found.
- ethereal/simpleCache dev-master requires predis/predis ^1.1#dev -> no matching package found.
- Installation request for ethereal/simplecache dev-master -> satisfiable by ethereal/simpleCache[dev-master].
Main Project composer.json:
{
"name": "ethereal/SimpleTable",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mathus13/SimpleConfig.git"
}
],
"require": {
"php": ">=5.3.9",
"doctrine/dbal": "^2.6#dev",
"ethereal/SimpleConfig": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"autoload": {
"psr-4": {
"Ethereal\\": "lib"
}
}
}
config library: when running composer update in SimpleTable, Simple Cache will not be included unless explicitly required in SimpleTable.
{
"name": "ethereal/SimpleConfig",
"type": "project",
"version": "0.0.1",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mathus13/SimpleCache.git"
}
],
"require": {
"php": ">=5.3.9",
"ethereal/SimpleCache": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"autoload": {
"psr-4": {
"Ethereal\\": "lib"
}
}
}
cache library: when running composer update in SimpleTable, predis can not be resolved.
{
"name": "ethereal/simpleCache",
"type": "project",
"version": "0.0.1",
"require": {
"predis/predis": "^1.1#dev",
"php": ">=5.3.9"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"autoload": {
"psr-4": {
"Ethereal\\": "lib"
}
}
}
ethereal/SimpleTable depends on ethereal/SimpleConfig in dev stability, which depends on ethereal/SimpleCache in dev stability, which depends on predis/predis in dev stability (version 1.1 hasn't been released yet).
Packages included into the main package cannot define any stability, the only stability allowed is the one in the main package. And that is "stable" by default.
You made ONE exception from this rule by depending on "dev-master" for SimpleConfig", but this is not inherited.
You have multiple solutions:
Tag your software. Tags declare it more stable than "dev", and it generally is a good idea to only use tagged software in production.
Include ALL your own packages that are needed in the main package, even if they are not directly used. This will add exceptions from the general stability for them, and allow Composer to resolve any sub dependencies.
You can add "minimum-stability":"dev" to the main composer.json, but this will also allow all other packages to be installed from a branch. Using branches however is a very bad thing, because you cannot easily go back to the version that was working before you did the update - the branch pointer moves only forward. Only tags will point to the same software forever.
Adding "prefer-stable":true" is some sort of workaround for the problem that 3 introduces for packages that are already available in a stable release version. However you still have the problem of not being able to go back to your own packages' earlier versions, because you are using a branch.
If you are still developing these packages, depending on branches may seem necessary. However, a good package will be able to be developed and tested standalone, with barely any foreign code present apart from interface definitions (which will be used to mock everything), so putting all code together into a mixture of repos with branches checked out usually is an invitation for writing code that isn't cleanly separated.
If any of these packages is already done (I'd say "good enough"), tag it and depend on that version instead of a branch. You can always release new versions if you find bugs or want to add new features.

How do I use the latest version of Zend Framework 2.3.5 using Composer PHP?

What do I add in my Composer.json file so it downloads version 2.3.5 of the Zend Framework? I've tried reading the Zend docs but it doesn't mention Composer.
{
"require" : {
"silex/silex": "~1.1",
"monolog/monolog": "~1.7",
"aws/aws-sdk-php": "~2.6",
"zendframework/zendservice-amazon": "2.3.5"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
},
"repositories": [
{
"type": "composer",
"url": "https://packages.zendframework.com/"
}
]
}
After I run composer update, it gives me this error message:
C:\Users\Ricky\graffiti-galore>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package zendframework/zendservice-amazon could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
In your require statement, it looks like you're using the wrong include for Zend. In your require statement:
"zendframework/zendservice-amazon": "2.3.5"
should be
"zendframework/zend-config": "2.3.5",
"zendframework/zend-http": "2.3.5"
Or if you want to avoid requiring a specific version number,
"zendframework/zend-config": "2.*",
"zendframework/zend-http": "2.*"
and for the part in minimum stability
"minimum-stability": "dev"
zendservice-amazon is not part of Zend Framework 2, none of the ZendService libs are. Its latest version is 2.0.3, all versions are listed here: https://packagist.org/packages/zendframework/zendservice-amazon
There is no version 2.3.5 for zendframework/zendservice-amazon, so obviously the install fails. Look at https://packagist.org/packages/zendframework/zendservice-amazon to see the available versions and fix the version selector (I'd suggest ~2.0).
You also don't need the repositories part in your composer.json, all the packages are also on Packagist, Composer's main and default package repository.

Composer dependency constraint

Is there a possibility to let composer install a package only when the PHP version is below a given version.
https://github.com/ircmaxell/password_compat
"ircmaxell/password-compat": "dev-master"
I have found this package to be useful because I have a webserver which runs on PHP 5.4 and I need the password_* functions which are only available >= PHP 5.5.
Yes, there is. You can find the details on the packagist website, but basically, the package/dependency should be defined with this requirement:
{
"name": "ircmaxell/password-compat",
"description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash",
"require": {
"php": "<5.5.*",
"phpunit/phpunit": "4.*"
}
}
As you can see, I've added "php": "<5.5.*" to the requirements for the package. You can add this requirement to your own composer.json file, by adding the dependency to your repositories array in the composer.json file, and add the requirements there:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ircmaxell/password_compat",
"require": {
"php": "<5.5.*",
}
}]
}
Something like that, I only have php5.5 installed, so I was unable to test this, though... but read through the documentation, I'm pretty sure it's possible.

How to use stable version of framework Zend 2.2.0?

I have just started to explore ZF2 framework for my project. Please note that I have not worked with ZF1 framework also.
Problem:
I want to know the way/method/steps to install a stable version Zend framework 2.2.0.
Things Done:
I am able to install ZEND skeleton application by following the documentation PDF i.e. from GitHub however I am not able to locate the steps to download zend stable version from site and use it on local. This has downloaded framework is showing version >2.2.0 RC1.
I am not very much sure about how much it is stable since zend framework itself stated it as release candidate.
I have used the steps described in PDF document with downloaded zend framework however after executing composer update and install there were no public directory got installed in root directory.
Please let me know if there is any steps to use stable version of Zend Framework using which I can build my application OR I must have to use 2.2.0 RC1 provided by zend skeleton application from Github.
Thanks in Advance.
try this composer.json
{
"name": "zendframework/zendframework",
"description": "Zend Framework 2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"minimum-stability": "dev",
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "dev-master",
"zendframework/zend-developer-tools": "dev-master",
"doctrine/annotations": ">=1.0",
"ircmaxell/random-lib": "dev-master",
"ircmaxell/security-lib": "dev-master",
"ocramius/proxy-manager": "0.3.*",
"phpunit/PHPUnit": "3.7.*"
},
"autoload": {
"psr-0": {
"Zend\\": "library/",
"ZendTest\\": "tests/"
}
}
}
I prefer to use some stable libraries like:
"zendframework/zendframework": "2.1.5",

Categories