Laravel new doesn't work in my local environment - php

I'm trying to create a new laravel app, but when I use the command "laravel new" I've got an error :
laravel new
Crafting application...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for phpunit/php-token-stream 2.0.0 -> satisfiable by phpunit/php-token-stream[2.0.0].
- phpunit/php-token-stream 2.0.0 requires php ^7.0 -> your PHP version (5.6.30) does not satisfy that requirement. Problem 2
- phpunit/php-token-stream 2.0.0 requires php ^7.0 -> your PHP version (5.6.30) does not satisfy that requirement.
- phpunit/php-code-coverage 4.0.8 requires phpunit/php-token-stream ^1.4.2 || ^2.0 -> satisfiable by phpunit/php-token-stream[2.0.0].
- Installation request for phpunit/php-code-coverage 4.0.8 -> satisfiable by phpunit/php-code-coverage[4.0.8].
Application ready! Build something amazing.
I'm on Windows 10, with php 5.6.30 installed.
I already tried to update composer itself, and laravel's installer (via composer global require "laravel/installer"), but it still doesn't work.
Last time I tried on this computer was three weeks ago, and it worked then.
Edit : I can't change my PHP version since it is the one I use on my server.

It looks like you are trying to download the latest realease of laravel. Though it is 5.4 but for some reason, it is downloading laravel's version that is compatible only with PHP7
Try with composer create-project --prefer-dist laravel/laravel blog "5.4.*" to install laravel 5.4

It's only the phpunit version. Change the version to smaller, like:
"phpunit/phpunit": "~5.7"
to
"phpunit/phpunit": "~5.0"

Related

Cant run composer install because a mismatch in PHP version

I have PHP version 8.1.5 as I'm writing this and I'm trying to experiment with older github repo like trix tutorial for example and a problem occurs when I tried to run composer install an error that said
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires php ^7.2.5 but your php version (8.1.5) does not satisfy that requirement.
Problem 2
- doctrine/inflector is locked to version 1.3.1 and an update of this package was not requested.
- doctrine/inflector 1.3.1 requires php ^7.1 -> your php version (8.1.5) does not satisfy that requirement.
Problem 3
- doctrine/lexer is locked to version 1.2.0 and an update of this package was not requested.
- doctrine/lexer 1.2.0 requires php ^7.2 -> your php version (8.1.5) does not satisfy that requirement.
Problem 4
- dragonmantank/cron-expression is locked to version v2.3.0 and an update of this package was not requested.
- dragonmantank/cron-expression v2.3.0 requires php ^7.0 -> your php version (8.1.5) does not satisfy that requirement.
Problem 5
- laravel/framework is locked to version v7.2.1 and an update of this package was not requested.
- laravel/framework v7.2.1 requires php ^7.2.5 -> your php version (8.1.5) does not satisfy that requirement.
...
I certainly don't want to downgrade my PHP version is there a way to upgrade those packages to be compatible with my PHP version?
so far I've tried
change my composer.json file
"require": {
"php": ">=8.1.5",
...
},
and
"require": {
"php": ">=7.2.5",
...
},
and running both composer install and composer update php --with-all-dependencies
You can also use Composer's --ignore-platform-reqs switch to install packages. It will install packages without complaining, but it's not guaranteed that your code will run.

Installing Amazon SDK via composer issue

Good day:
I'm running PHP 5.6 and I'm trying to install aws/aws-sdk-php however, getting error:
$ composer require aws/aws-sdk-php
./composer.json has been updated
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
- symfony/translation v4.1.3 requires php ^7.1.3 -> your PHP version (5.6.20) does not satisfy that requirement.
- symfony/translation v4.1.3 requires php ^7.1.3 -> your PHP version (5.6.20) does not satisfy that requirement.
- Installation request for symfony/translation == 4.1.3.0 -> satisfiable by symfony/translation[v4.1.3].
Installation failed, reverting ./composer.json to its original content.
Not sure why I'm getting this issue as aws/aws-sdk-php requires minimum PHP 5.6 however, these dependencies requires php 7. I already have these dependencies installed in my vendor directory (through composer)
"require" : {
"jenssegers/proxy" : "^2.2",
"league/oauth2-client" : "0.12.1",
"zendframework/zend-diactoros" : "^1.7",
"nesbot/carbon" : "^1.22"
}
As #rob006 mentioned, I needed to delete my vendor directly and run composer again.
This main reason for the issue is that I ran composer install initially on a PHP 7 system and then ran it subsequently on php 5.6 which cause the issue. Another fix is to set the platform version of php in the composer.json file.

API Platform v1.1.1 & Symfony 3.2.8 composer conflict

I have Symfony Demo Application up and running and now I'm trying to install API Platform as a standalone bundle.
I'm using PHP 7.0.10 with latest composer, but my previous test was using PHP 5.6.20.
When I try to add API Platform Core as a dependency, I get the following error message:
$ composer require api-platform/core
Using version ^1.1 for api-platform/core
./composer.json has been updated
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
- Installation request for symfony/symfony (locked at v3.2.8, required as ^3
.2) -> satisfiable by symfony/symfony[v3.2.8].
- api-platform/core v1.1.0 requires phpdocumentor/reflection ^1.0.7 -> satis
fiable by phpdocumentor/reflection[1.0.7].
- api-platform/core v1.1.1 requires phpdocumentor/reflection ^1.0.7 -> satis
fiable by phpdocumentor/reflection[1.0.7].
- Conclusion: don't install phpdocumentor/reflection 1.0.7
- Installation request for api-platform/core ^1.1 -> satisfiable by api-plat
form/core[v1.1.0, v1.1.1].
Installation failed, reverting ./composer.json to its original content.
In your composer.json file:
Find:
"symfony/symfony": "3.2.*",
Replace with:
"symfony/symfony": "3.3.*",
...or:
"symfony/symfony": "^3.2.*",
You'll probably need (want) to run composer update first, THEN add your api-platform package with composer require api-platform/core so you have all the dependencies properly loaded, but it's not essential.
With PHP 7.x, you should be using ^2.0, e.g.
composer require api-platform/core ^2.0
Note: To workaround PHP 7.x requirements, you can try to add --ignore-platform-reqs.
If you get the error about minimum-stability, change it to beta in your composer.json file.
Source: Compatibility issue when using composer require with symfony 3.1.4 at GitHub.
See: Installing API Platform Core.

Why composer install --no-dev does not work?

I am developing a package library which has regular dependencies and one dev dependency. Composer recommends to not include the composer.lock file for libraries, so here is the composer.json
{
"name": "myself/mypackage",
"require": {
"php": ">=5.6",
"nesbot/carbon": "~1.20"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
}
}
I want this to be compatible for use with applications running PHP 5.6, and I want to develop it using the latest PHPUnit testing tools which require PHP 7.
On the travis continuous integration testing server, I have a build matrix which runs the PHPUnit tests on PHP > 7 and a linting script:
composer install
./lint-php.bash
phpunit
and on PHP < 7, simply lint the source code:
composer install --no-dev
./lint-php.bash
However, it fails because it ignores the --no-dev flag and tries to install the dev dependency anyway.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/phpunit 6.0.7 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.6 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.5 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.4 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.3 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.2 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.1 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.0 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- Installation request for phpunit/phpunit ^6.0 -> satisfiable by phpunit/phpunit[6.0.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7].
Why is it ignoring the --no-dev flag? I just want it to install my regular dependencies and to ignore the require-dev section.
Despite the recommendation, this is because you don't have a composer.lock file, and is actually a requested feature.
First, it tries to resolve all dependencies. If this fails, it aborts. Next, it runs the actual install, and at that time ignores the dev dependencies. Your problem is that it couldn't pass the first step for resolution. So it's not that it ignored the --no-dev flag, it just never made it that far.
Option 1
If you include a composer.lock file, then it skips the dependency resolution and goes straight to installation at which time it will skip the dev dependencies.
Option 2
Since you're not including a library, but rather an executable tool, then instead of fighting the potential dependency conflicts between other dev tools you may include later, just pull it out of composer entirely and use phive (The PHAR Installation and Verification Environment).

Laravel passport installation error

I've just downloaded the latest laravel 5.3 and I'm trying to install passport, but I'm getting the following composer error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/passport v2.0.0 requires illuminate/http ~5.4 -> satisfiable by illuminate/http[v5.4.0].
- laravel/passport v2.0.1 requires illuminate/http ~5.4 -> satisfiable by illuminate/http[v5.4.0].
- Conclusion: don't install illuminate/http v5.4.0
- Installation request for laravel/passport ^2.0 -> satisfiable by laravel/passport[v2.0.0, v2.0.1].
Installation failed, reverting ./composer.json to its original content.
Composer .json file
http://pastebin.com/ne4RkL96
It happens, because after releasing Laravel 5.4, this package also had been updated to v 2.0 and requires Laravel 5.4. But you are using Laravel 5.3. Try to install earlier version:
composer require laravel/passport ^v1
Also, you can learn about the versions of this package here:
Laravel Passport
For Laravel 5.3.
In your composer.json file put "laravel/passport": "~1.0" and run "composer update" command.
In line with Rashad's answer as it helped me out, you need a version of passport less than major version 2. This can be accomplished with several version strings ^v1, v1.x, >= 1 < 2 and several other combinations.
I used this: php composer.phar require laravel/passport ^v1 and it worked awesomely.
Install laravel passport version 7:
> composer require laravel/passport:7.5.1

Categories