Composer could not find a composer.json

后端 未结 11 670
南方客
南方客 2020-12-29 07:52

I tried to install composer via brew per:

In usr/local/bin (which was not on Mavricks and I had to make personally) I did.

brew tap jose

相关标签:
11条回答
  • 2020-12-29 08:15

    You are in wrong directory. cd to your project directory then run composer update.

    0 讨论(0)
  • 2020-12-29 08:15

    In my case, I did not copy all project files to the folder where I was running composer install. So do:

    1. Copy your project files (including the composer.json) to folder
    2. open CMD (I am using ConEmu), navigate to the new folder, run composer install from there
    3. It should work or throw errors in case the json file is not correct.

    If you just want to make composer run, create a new composer.json file with for example:

    {
        "require": {
            "php": ">=5.3.2"
        }
    }
    

    Then run composer install.

    0 讨论(0)
  • 2020-12-29 08:15

    You could try updating the composer:

    sudo composer self-update
    

    If that doest works remove composer files & then use: SSH into terminal & type :

    $ cd ~
    $ sudo curl -sS https://getcomposer.org/installer | sudo php
    $ sudo mv composer.phar /usr/local/bin/composer
    $ sudo ln -s /usr/local/bin/composer /usr/bin/composer
    

    If you face an error that says: PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar

    /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
    /sbin/mkswap /var/swap.1
    /sbin/swapon /var/swap.1
    

    To install package use:

    composer global require "package-name"
    
    0 讨论(0)
    • Create a file called composer.json
    • Make sure the Composer can write in the directory you are looking for.
    • Update your composer.

      This worked for me
    0 讨论(0)
  • 2020-12-29 08:19

    At first you should run:

    php artisan key:generate
    
    0 讨论(0)
  • 2020-12-29 08:21

    I encountered the same error, and was able to solve it as follows:

    1. composer diagnose to see if something is wrong with the version of composer installed
    2. composer self-update to install the latest version
    3. composer update to update your composer.json file.
    0 讨论(0)
提交回复
热议问题