Apodemus
Apodemus

Reputation: 618

UnexpectedValueException when creating a new Symfony project

I want to make a new Symfony project but it gives me an UnexpectedValueException.

whether I use: symfony new my_project_name --full or composer create-project symfony/website-skeleton my_project_name, I get this response:

Creating a "symfony/website-skeleton" project at "./my_project_name"
Installing symfony/website-skeleton (v5.1.99)
  - Installing symfony/website-skeleton (v5.1.99): Loading from cache
Created project in C:\xampp\htdocs\my_project_name
Loading composer repositories with package information
Updating dependencies (including require-dev)


  [UnexpectedValueException]
  Invalid version string "5.x"


create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]

I'm following the exact instructions on symfony.com - Installing & Setting up the Symfony Framework

It only generates a composer.json file and a LICENSE file.

composer.json looks like this:

{
    "name": "symfony/website-skeleton",
    "type": "project",
    "license": "MIT",
    "description": "A skeleton to start a new Symfony website",
    "require": {
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "symfony/flex": "^1.3.1"
    },
    "flex-require": {
        "sensio/framework-extra-bundle": "^5.1",
        "symfony/asset": "*",
        "symfony/console": "*",
        "symfony/dotenv": "*",
        "symfony/expression-language": "*",
        "symfony/form": "*",
        "symfony/framework-bundle": "*",
        "symfony/http-client": "*",
        "symfony/intl": "*",
        "symfony/mailer": "*",
        "symfony/mime": "*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/notifier": "*",
        "symfony/orm-pack": "*",
        "symfony/process": "*",
        "symfony/security-bundle": "*",
        "symfony/serializer-pack": "*",
        "symfony/string": "*",
        "symfony/translation": "*",
        "symfony/twig-pack": "*",
        "symfony/validator": "*",
        "symfony/web-link": "*",
        "symfony/yaml": "*"
    },
    "require-dev": {
    },
    "flex-require-dev": {
        "symfony/debug-pack": "*",
        "symfony/maker-bundle": "^1.0",
        "symfony/profiler-pack": "*",
        "symfony/test-pack": "*"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": [
        ],
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.1.*"
        }
    }
}

Upvotes: 4

Views: 2155

Answers (2)

Maxime P
Maxime P

Reputation: 74

Uninstall and reinstall composer on your computer.

I had the same problem and it worked for me.

Upvotes: 1

Stan Alferson
Stan Alferson

Reputation: 1

Try to remove folders: vendor/ and var/

  • Run composer update
  • After that checkout symfony console cache:clear

If there are any errors, then run composer recipes:install --force -v. And resolve it.

Upvotes: 0

Related Questions