Search code examples
phpjsoncomposer-phpphar

Access composer.json /composer.phar


I have installed composer.phar in the following directory:

/public_html/composer

I have already added on package to the composer.json as below:

{
    "require": {
        "stripe/stripe-php": "2.*"
    }
}

That was some time ago. I would now like to install another package, using composer. However, I cannot access it. I am trying to do the following in SSH/Terminal:

root@host [~]# composer.phar
-bash: composer.phar: command not found

Then I try to:

root@host [~]# cd public_html
root@host [~/public_html]# cd composer
-bash: cd: composer: No such file or directory
root@host [~/public_html]# 

What am I doing wrong? In FTP I can see the composer is located in the /public_html/ folder, but I can't acccess it?

EDIT:

ls -l composer 

gives me:

/bin/ls: Can't access composer: No such file or directory

Using ls -a I get:

./             .bwusage.sqlite  error_log       perl5/        .spamassassin/
../            .composer/       .forward        php.ini.new   .ssh/
.accesshash    .cpanel/         .gnupg/         php.ini.orig  support/
.bash_history  cpanel3-skel/    .HttpRequest/   .pki/         .tcshrc
.bash_logout   .cpanm/          .lesshst        public_ftp/   tmp/
.bash_profile  .cpobjcache/     .MirrorSearch/  public_html/  .trustwavereqs
.bashrc        .cshrc           .my.cnf         .rnd          .viminfo

Solution

  • The problem I believe is that /public_html/composer is under the root / and there is also a public_html under /root (home directory for root user) directory

    use pwd to check where you are at the moment and use ls /public_html/composer to see if composer.phar is in this directory.

    You can run: php /public_hmtl/composer/composer.phar.

    In order to be able to run it as composer you must mv the composer.phar to a directory that is included in your PATH variable.

    For example:

    mv /public_html/composer/composer.phar /usr/bin/composer