Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Composer with local dependencies [closed]

I know Composer because of Symfony2 but now I would like to use it as a standalone part. I followed the instructions that its documentation said but don't know how to set a local library as a dependency, how to load it?

In other words, how to load a local repository using Composer instead of referencing a remote one?

like image 242
haxpanel Avatar asked Nov 14 '12 21:11

haxpanel


People also ask

How do you solve a composer error?

To solve the Memory exhausted issue, you can try running composer with an Unlimited memory flag like this: php -d memory_limit=-1 /usr/local/bin/composer [COMMAND] or php -d memory_limit=-1 composer. phar [COMMAND] when using a local composer. If that doesn't help, you can upgrade your hosting plan.

Why is my composer not working?

Make sure you have no problems with your setup by running the installer's checks via curl -sS https://getcomposer.org/installer | php -- --check . Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer.

How do I remove unused dependencies from composer?

Now just open the composer. json file and delete the dependency which you want to remove. Now we just need to run the composer update command once more and it will remove all the phpunit dependencies which we don't want as shown below: Running composer update once again.


1 Answers

I've just found the solution! I did everything fine but misstyped the namespace of the dependency I wanted to autoload. So the answer to this question is

  1. I installed composer: curl -s https://getcomposer.org/installer | php
  2. Created a file composer.json than put the following content into it:

    {
        "autoload": {
            "psr-0": {
                "MyNamespace":"src/"
            }
        }
    }
    
  3. run: php composer.phar install

  4. include into the index.php ../vendor/autoload.php
like image 91
haxpanel Avatar answered Oct 02 '22 12:10

haxpanel