Unable to figure out the series of errors by composer while installing Laravel

782 views Asked by At

For last 3 days, I am trying to install laravel 5.5 in my system(windows 8.1) through composer and getting a series of errors one after other. So I am asking some questions in order to clear my doubts which are still doubted after more than 20-25 hour of research on various blogs and SO.

  1. I have installed php 7 in c:\php.
  2. After that, I have installed composer using composer installer and did nothing after that, like setting PATH on environment setting.
  3. I found that I have to create a composer.json file which I have copied from Github and shown below, but I don't know where to keep this composer.json file so I created this file on C:\Users\MyPC (i.e. my home directory).

    {
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.0.0",
        "fideloper/proxy": "~3.3",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~6.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
     }
    }

    Please check the code above if I have committed any mistake.

  4. After that I executed "composer update" command which downloaded a lot of files and placed in C:\Users\MyPC\vendor folder (I think), but throws an error at last which I can't remember.
  5. After that I executed "composer install" command and get this error shown below.

enter image description here

This is my problem and I am not able to figure out what to do.

I have a couple of more doubt:

a - composer create-project --prefer-dist laravel/laravel NAME_OF_PROJECT can also be used to set up new project then why we use composer global require “laravel/installer” and then laravel new NAME_OF_PROJECT method. What are the benefits of using this method.

b - What are the steps to follow after the installation of the composer using the installer for setting up a new laravel project. What are the best practices to structure the project folder?

Please help me. I am learning laravel but don't know how to deal with this composer stuff and installing laravel as most or all of the tutorial starts with creating new project file .they don't teach how to install them.

1

There are 1 answers

0
Prateek On BEST ANSWER

Ok so a lot of research and try and errors I figured out a way that worked for me. I am using Windows 8.1.

  1. I have installed php 7 in c:\php.

Note : Download php from http://php.net/downloads.php. Download Non Thread Safe version in zip format and extract it to the desired folder (I extracted in C:\php).

  1. After that I have installed composer using composer installer and did nothing after that, like setting PATH on environment setting, Installer will do it for you.

Download Composer Installer from https://getcomposer.org/download/.

  1. After that I have downloaded laravel from github and exctrated to the desired project folder.

Download Laravel latest version from https://github.com/laravel/laravel

  1. After that I ran "composer self-update"command.
  2. After that I ran "composer update"command.
  3. After that I ran "composer global require “laravel/installer”"command. This command will install Laravel Installer.

Now I can go to the project folder directory and run "laravel new myProjectName" command to create new laravel project.