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.
Related
I have a Symfony 4 project and am trying to install this package for working with AWS DynamoDB.
When I run composer require oasis/dynamodb-odm I get an error saying oasis/dynamodb-odm v0.5.3 requires symfony/console ^3.2 -> no matching package found. Attempting to run composer require symfony/console:^3.2 also results in the "Could not find package..." error.
As I am using Symfony 4, composer commands are intercepted by Symfony Flex and some extra stuff happens. Interestingly, there is a Flex recipe for symfony/console:3.3 but not 3.2 which I imagine might be the problem.
My understanding of the caret is that it should allow minor version bumps, so I wonder why console v3.3 is not installed instead.
I would like to use this package, and there aren't many DynamoDB PHP offerings out there, so how can I resolve this issue?
if you checkout the composer.json file of the package, you can see the following
"require" : {
"php" : ">=5.6",
"doctrine/annotations": "^1.4",
"oasis/aws-wrappers" : "^2.10",
"oasis/logging" : "^1.0",
"doctrine/common" : "^2.7",
"symfony/console" : "^3.2",
"symfony/finder" : "^3.2"
},
meaning it is compatible with symfony3 only.
Probably you can fork the repo and try changing the version numbers and test it. If it works you can install it.
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.
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
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.
I am working on a project with the php and mongodb stacks. I need the assistance of an ODM to speed up development time. A problem I have now however is this line,
$ composer require "doctrine/mongodb-odm=~1.0"
in which directory should i execute this command, the application's root directory or anywhere in my command line???
Copy the following to composer.json
{
"require": {
"doctrine/mongodb-odm": "~1.0",
"doctrine/mongodb-odm-bundle": "~3.0"
},
}
after that run the command in respective folder
php composer.phar update doctrine/mongodb-odm doctrine/mongodb-odm-bundle