8

My profesionnal network block internet access. Some month ago I download the Silex framework from an archive (which contains composer.json file) and the composer.phar one's, then I transfer them on my desktop throught HDD.

My composer.json that I customized:

{
    "name": "user/silex",
    "require": {
        "silex/silex": "1.2"
                , "twig/twig": ">=1.8,<2.0-dev"
                , "doctrine/dbal": "2.2.*"
                , "symfony/security": "~2.3"
                , "symfony/security": "~2.3"
    },
    "autoload": {
        "psr-4": {
            "Portal\\": "src/"
        }
    }
}

It works fine, my autoload customization too.

Today I want to add the monolog/monolog package, so I manually import it from an other computer.

I place it into my vendor folder, I add the following line to my composer.json file:

, "monolog/monolog": ">=1.0.0"

I run on the console:

php composer.phar dumpautoload

It outputs: Generating autoload files

Then it stop without error, but the monolog namespace doesn't appear into my /vendor/composer/autoload_*.php files.

What did I miss?

3
  • 2
    I have a feeling that the best way to do this would be to specify your own custom repository and download the actual repositories to your computer and then reference your local repositores. I don't know exactly how to do that though, or if its possible - getcomposer.org/doc/05-repositories.md Oct 15, 2014 at 9:23
  • @edmondscommerce You get it, I have to create an artifact repository. Oct 16, 2014 at 8:00
  • Cool, that looks like the way forwards. Would be good for you to do a detailed answer on exactly how to do it for the benefit of others hitting this question Oct 16, 2014 at 8:08

2 Answers 2

8

Thanks to edmondscommerce's comment I found the solution:

I update my main composer.json file with an artifact respository (and I disable the packagist one):

{
    "name": "user/silex",
    "repositories": [
        {
            "type": "artifact",
            "url": "artifact/"
        }, {
            "packagist": false
        }
    ], "require": {
        "silex/silex": "1.2"
                , "twig/twig": ">=1.8,<2.0-dev"
                , "monolog/monolog": "1.*"
                , "doctrine/dbal": "2.2.*"
                , "symfony/security": "~2.3"
    },
    "autoload": {
        "psr-4": {
            "Portal\\": "src/"
        }
    }
}

Then I put a folder called artifact according to the url put in the composer.json file.

I create into this folder a zip called monolog-monolog-1.8.zip with the library I want to add.

Then just launch a composer update command!

Be carefull, zip's root must contain a composer.json file, and this composer.json file must contain a version!

1

If you do not want to create a custom repository, you can also run composer install (or composer update) on a copy that is on a network-connected computer. Then you can copy over the newly added and extracted component into the vendor folder on the machine without internet access. Note that you also need to copy vendor/composer/installed.json to let composer know that the new package has been installed. Once you have copied all these files, you can run composer install on the machine without internet access and it will not try to install anything and dump autoload files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.