I have a composer.json like this:
{
"require": {
"symfony/yaml" : "dev-master",
"symfony/console" : "dev-master",
"ebuildy/ebuildy" : "dev-master",
"keboola/php-encryption": "dev-master",
"pear-pear.php.net/mail_mime" : "*",
"pear-pear.php.net/http_request2" : "*",
"pear-pear.php.net/mail_mimedecode" : "*",
"microsoft/windowsazure": "*",
"rollbar/rollbar": "dev-master",
"facebook/php-sdk-v4" : "4.0.*",
"happyr/linkedin-api-client": "dev-master",
"zircote/swagger-php" : "dev-master",
"google/apiclient" : "dev-master"
},
"autoload": {
"psr-0": {
"bizlunch": "src/"
}
},
"minimum-stability": "dev"
}
Just added "google/apiclient", I want to install this new package without checking other packages requirements (because on my dev machine "keboola/php-encryption" complains about crypt ext missing and other stuff).
What is the right command? Tried already update PACKAGE, but this fails:
$root: php composer.phar update google/apiclient
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
- keboola/php-encryption dev-master requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
If you want to ignore the specifics of your local system, you can use --ignore-platform-reqs flag. Keep in mind that it may result in unusable lockfile in production.
Let's show it on imaginary scenario:
you don't have ext-crypt locally and neither in production.
there is package cryptX that
in cryptX:1.0 uses lib-crypt-polyfill (that does what ext-crypt does using PHP code)
but in cryptX:2.0 they changed the dependency to ext-crypt.
Now if you were to install it normally, you'd get version 1 (which is the only one meeting the dependencies). But with --ignore-platform-reqs it just works as if whatever it wants is available in your system. So it happily installs version 2, which does not work on you machine, but what's more it won't work on you production server neither.
As easy as
php composer.phar update google/apiclient
or you can specify several individual packages as
php composer.phar update google/apiclient zircote/swagger-php rollbar/rollbar
Maybe PHP extension mcrypt isn't installed on your machine. See how to install it here http://php.net/manual/en/mcrypt.setup.php
In an Ubuntu machine run :
apt-get install php5-mcrypt
php5enmod mcrypt
service apache2 restart
Related
I have been trying to deploy a php app on heroku but I keep getting this error:
-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
ERROR: neither your composer.json 'require' section nor any
dependency therein requires a runtime version, but 'require-dev'
or a dependency therein does. Heroku cannot automatically select
a default runtime version in this case.
Please add a version requirement for 'php' to section 'require'
in composer.json, 'composer update', commit, and deploy again.
! ERROR: Couldn't load 'composer.lock'; it must be a valid lock
file generated by Composer and be in a consistent state.
Check above for any parse errors and address them if necessary.
Run 'composer update', add/commit the change, then push again.
! Push rejected, failed to compile PHP app.
! Push failed
anyone know how I can solve it?
So this is what I would look at, and sorry if any of these assumptions are wrong, or I am going through stuff you have already done.
Your composer.json should be divided up into require and require-dev. Require would be installed in production with require-dev added locally.
{
"name": "something/something",
"description": "A description of my project",
"type": "project",
"require": {
"php": ">=5.5.9",
"doctrine/cache": "1.4.*",
"elasticsearch/elasticsearch": "~2.0",
"monolog/monolog": "~1.0",
"knplabs/github-api": "~1.2",
"ezyang/htmlpurifier": "~4.6",
"easyrdf/easyrdf": "0.9.*",
"hoa/compiler": "~2.15",
"hoa/visitor": "~1.15",
"collectiveaccess/service-wrapper": "v1.1",
"phpoffice/phppresentation": "dev-master",
"phpoffice/phpword": "v0.13.*"
},
"require-dev": {
"phpunit/phpunit": "4.3.*",
"maximebf/debugbar": ">=1.0.0"
}
}
If you have not got composer installed you need to do so. https://www.hostinger.com/tutorials/how-to-install-composer
Run php composer install in the first instance of php composer update later on to install your dependencies.
Please commit everything except, the vendor files and any cache or logging. This would include composer.lock which is a list of installed dependencies and the versions you are using.
Heroku will install these dependencies in production making sure it uses the same version as specified in the lock file.
When I use composer to install packages in my project I am only able to do so if I update my json file manually.
For example, if I run the following command in Git-Bash in my project directory (which contains my composer.phar and composer.json file):
php composer.phar require php-di/slim-bridge
It returns the following error:
[Invalid Argument Exception]
Could not find package
php-di\slim-bridge at any version for your minimum-stability (stable).
Check the package spelling or your minimum stability.
However, if i were to just update my json file to the following (example I've provided contains multiple packages I am using in my project):
{
"require": {
"slim/slim": "^3.0",
"slim/twig-view": "^2.1",
"illuminate/database": "^5.2",
"respect/validation": "^1.0",
"slim/csrf": "^0.6",
"slim/flash": "^0.1",
"phpmailer/phpmailer": "^5.2",
"php-di/slim-bridge":"^1.0"
},
"autoload":{
"psr-4": {
"App\\": "app"
}
}
}
... And I run the command: $ php.composer.phar update
Everything installs to project correctly.
What is going on that I am not able to install packages using the require method thus making me resort to manually updating my json file each time?
Since I am using windows, I used the windows installer for composer rather than install through command line and I got this working correctly. Much much easier now since I don't have to update my JSON files manually.
I am trying to install PHPUnit/Runner/Version.php using PHP composer and I get the following error.
The requested package phpunit/phpunit-runner could not be found in any version, there may be a typo in the package name.
I am not sure if I am install the wrong package or what. The following is what I have in my composer.json file.
{
"require-dev": {
"phpunit/phpunit": "4.1.*",
"phpunit/php-invoker": "*",
"phpunit/dbunit": ">=1.2",
"phpunit/phpunit-selenium": ">=1.2",
"phpunit/phpunit-story": "*",
"phpunit/phpunit-runner": "*" - with this removed that file is unavailable
}
}
Any help would be great.
The class PHPUnit_Runner_Version is part of the core PHPUnit package phpunit/phpunit in any version.
So there is no need to require it seperately because the package name you invented does not exist.
You probably have a different problem you didn't ask in this question about some software not being able to require this class, but this likely isn't being solved this way.
When moving from our own PHP custom buildpack to the supported Heroku one we are running into a problem. Heroku requires us to add certain extensions to the composer.json "require" part, but when you then try to update locally it fails because these packages do not exists in the repo.
Config file:
{
"config":{
"github-oauth":{
"github.com":""
}
},
"require": {
"php": "*",
"ext-newrelic": "*",
"ext-memcached": "*",
"aws/aws-sdk-php": "2.*",
"rollbar/rollbar": "*",
"yiisoft/yii": "1.1.15",
"cloudinary/cloudinary_php": "1.0.11",
"geoip/geoip": "v1.14",
"sendgrid/sendgrid": "2.1.1",
"swiftmailer/swiftmailer": "v5.2.1",
"crisu83/yiistrap": "dev-bs3"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpunit/dbunit": ">=1.2",
"phpunit/php-invoker": "*",
"phpunit/phpunit-selenium": ">=1.2",
"phpunit/phpunit-story": "*",
"squizlabs/php_codesniffer": "1.*",
"phpmd/phpmd" : "1.4.*",
"phploc/phploc": "*",
"pdepend/pdepend" : "1.1.0",
"sebastian/phpcpd": "*",
"mayflower/php-codebrowser": "~1.1"
}
}
Error message:
11:08:55 {development} /Volumes/Development/web$ 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 PHP extension ext-newrelic * is missing from your system.
Problem 2
- The requested PHP extension ext-memcached * is missing from your system.
Any ideas ?
You need to install those extensions. The assumption is that you develop, run and test your code locally during development using roughly the same components and environment as in production, so if you use memcache in production, you also use it locally. That ensures you're not running into nasty surprises because different datastores behave differently etc. Also see http://12factor.net/dev-prod-parity
Exception to the rule: you don't need to install the New Relic extension; it's enabled automatically on push if you provision the New Relic add-on (by detecting NEW_RELIC_LICENSE_KEY env var), see https://devcenter.heroku.com/articles/php-support#extensions (it is of little use locally on a developer's box, and can be a bit troublesome to install).
Installing the extensions fixed this for me (the newrelic extension is giving me trouble but that's another question.)
(Answer was posted here, but the person removed it again.)
Sorry for duplication of this question with another one. I can't solve my problem.
I am working on a project based on Ratchet. I am trying to run the Push Integration example. So, in order to run, I should use composer to get some dependencies. I make a composer.json file like below:
{
"autoload": {
"psr-0": {
"MyApp": "src"
}
},
"require": {
"cboden/ratchet": "0.3.*",
"react/zmq": "0.2.*|0.3.*"
}
}
When I execute composer on it, below error occurrs:
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- react/zmq v0.3.0 requires ext-zmq * -> the requested PHP extension zmq is missing from your system.
- react/zmq v0.2.0 requires ext-zmq * -> the requested PHP extension zmq is missing from your system.
- Installation request for react/zmq 0.2.*|0.3.* -> satisfiable by react/zmq[v0.2.0, v0.3.0].
Below you can find composer.json of Ratchet and ZMQ:
ZMQ:
{
"name": "react/zmq",
"description": "ZeroMQ bindings for React.",
"keywords": ["zmq", "zeromq"],
"license": "MIT",
"require": {
"php": ">=5.4.0",
"ext-zmq": "*",
"evenement/evenement": "~2.0",
"react/event-loop": "0.4.*"
},
"require-dev": {
"ext-pcntl": "*"
},
"autoload": {
"psr-0": { "React\\ZMQ": "src" }
},
"extra": {
"branch-alias": {
"dev-master": "0.4-dev"
}
}
}
Ratchet:
{
"name": "cboden/ratchet"
, "type": "library"
, "description": "PHP WebSocket library"
, "keywords": ["WebSockets", "Server", "Ratchet", "Sockets"]
, "homepage": "http://socketo.me"
, "license": "MIT"
, "authors": [
{
"name": "Chris Boden"
, "email": "cboden#gmail.com"
, "role": "Developer"
}
]
, "support": {
"forum": "https://groups.google.com/forum/#!forum/ratchet-php"
, "issues": "https://github.com/ratchetphp/Ratchet/issues"
, "irc": "irc://irc.freenode.org/reactphp"
}
, "autoload": {
"psr-0": {
"Ratchet": "src"
}
}
, "require": {
"php": ">=5.3.9"
, "react/socket": "0.3.*|0.4.*"
, "guzzle/http": "~3.6"
, "symfony/http-foundation": "~2.2"
, "symfony/routing": "~2.2"
}
}
What is wrong? Please give me a solution.
Thanks in advance :)
Ok, here we go...
You must have ZMQ and ZMQ binding installed previously in operation system.
The following exemples is based on Debian Linux but it should work in other OS.
First:
Installing 0MQ:
Go to http://zeromq.org/area:download and choose a package according your OS, in my case I've choosed
POSIX tarball Stable Release 4.0.4.
~$ tar -xvf zeromq-4.0.4.tar
~$ cd zeromq-4.0.4
~$ ./configure
~$ make
~$ sudo make install
Ok, we just have installed ZMQ now need install zmq php binding...
Make sure you having php-dev and php pear installed. If no:
~$ sudo apt-get install php5-dev php-pear
~$ sudo pecl install zmq-beta
Ok, we have now ZMQ and php binding (ext-php) installed but we should add "extension=zmq.so" (Or extension=php_zmq.dll on windows) to php.ini:
In my case:
~$ sudo nano /etc/php5/apache2/php.ini
NOTE: If PHP version is 5.4.x (or 5.4+, but I haven't tested yet...) you will need to add a zmq.ini file in /etc/php5/conf.d and put "extension=zmq.so":
~$ sudo nano /etc/php5/conf.d/20-zmq.ini
Reloadind HTTP server (in my case apache):
~$ sudo service apache2 reload
WOW!!! Now we gonna to update composer requirements:
~$ composer --verbose update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing react/zmq (v0.3.0)
Downloading: 100%
Extracting archive
Writing lock file
Generating autoload files
If you are still getting the same error even after following the above answer then it might be because of incorrect php.ini used usually by composer.
You have to update the ini of CLI PHP also.
If you run the command php --ini from inside your terminal then you should see something like following:
This .ini meant for different usage than /etc/php5/apache2/php.ini. So, update that /etc/php5/cli/php.ini and add extension=zmq.so in it, if you think you already installed the extension following a correct workflow.
Hope you will get rid off that the requested PHP extension zmq is missing error while using composer installation.
If you are using Xampp on windows, then follow these steps
Download all dll here http://pecl.php.net/package/zmq to your matching OS.
Make sure you got the right one (x86 or x64) and that it is either thread safe or non- thread safe. How would you know? Time to play DLL roulette.
Copy libzmq.dll to your xampp/php/
Copy php_zmq.dll to your php extension directory (eg. xampp/php/ext/)
Then add this to your php.ini extension=php_zmq.dll