3

I'm trying to install Symfony on a server, which has no connection to the internet. I copied composer on the server but when i try to install it i get this error

Connection Error [ERR_CONNECTION]: Unable to connect to getcomposer.org

Is there any possible way to install symfony without active connection to the internet; like download the framework, put it on the server and then run the composer offline? Or does it have too many dependencies, which would be included?

I've already googled but couldn't find a satisfying solution.

User
  • 51
  • 2
  • 7

4 Answers4

4

Do

composer install -o

to install. Then do all preparations like clear cache in prod/dev build assets and dump them

   php app/console cache:clear && php app/console cache:clear -e prod --no-debug
   php app/console assetic:dump -e prod --no-debug
   php app/console assets:install web --symlink --relative

then push/ftp your project to a server. I highly recomend you to run

composer dumpautoload -o

in order to update autolaod files on the server

UPDATE:

You could (should) also run a symfony's after-install script (after dumping autoload) in order to edit/update your parameters.yml on the Server, since db-access, mailer_transport will be probably different than on your dev-machine

composer run-script post-install-cmd
php app/console cache:clear -e prod --no-debug

then just run

php/console list

if you'll get a list of all available commands => your symfony app was successfully installed and runs

Community
  • 1
  • 1
V-Light
  • 3,065
  • 3
  • 25
  • 31
  • Actually I don't think you need to clear cache and dump assets in advance. You should be able to run those commands on the server even if it's offline. – Francesco Abeni May 19 '17 at 13:44
  • I installed composer and copied all the files' project, but when i try to open the symfony project i get this error "the requested URL was not found on this server" Do you have any idea how to configure it ? – User Jun 15 '17 at 13:10
1

You can run composer on computer with connection to internet and copy all directory with files.

Composer to work mast make connection to internet, to check new version of package.

janek1
  • 256
  • 1
  • 3
  • 17
  • 1
    Do you mean i should run composer on my machine and then copy symfony project to the server without need to install composer on the server? – User May 19 '17 at 09:38
  • I installed composer and copied all the files' project, but when i try to open the symfony project i get this error "the requested URL was not found on this server" Do you have any idea how to configure it ? – User Jun 15 '17 at 13:08
  • Thank you @janek1 but this solution doen't work for me. Do you have any other idea ? – User Jun 22 '17 at 17:58
1

The short answer is yes and there are several ways to do that

As others have suggested the best choice is to build your project (install Symfony, install Composer, update dependencies) on a system that is connected to the internet and then just copy the project on the server.

Warning

The system where you build the project should be as similar as possible to the actual server (I mean PHP version, MySQL version, and so on) else the project may breaks.

You may want to build a Virtual Machine to make it really similar, which is good for development also. In that case you may take a look at tools like Ansible and Vagrant.

Francesco Abeni
  • 4,190
  • 1
  • 19
  • 30
1

I've the same problem in symfony3.

Solution:

  1. Create archive of project - for safety.
  2. Copy project form server to computer with internet access (all files & directory): laptop.
  3. Run composer update on laptop.
  4. On server:

    rm -rf app/*
    rm -rf bin/*
    rm -rf var/cache/*
    rm -rf var/logs/*
    rm -rf var/sessions/*
    rm -rf vendor/*
    rm composer.json
    rm composer.lock

  5. Copy from laptop to server files to directory: app/, bin/, vendor/ and composer.json, composer.lock

Its work for me :-)

Grene
  • 434
  • 6
  • 18
  • Thanks @Grene for your solution but it doesn't work for me. I've updated composer and then copied the project from laptop to server but still not working. Do you have any other solution? – User Jun 22 '17 at 17:53