oliverbj
oliverbj

Reputation: 6050

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

Upvotes: 0

Views: 1345

Answers (2)

orestiss
orestiss

Reputation: 2283

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

Upvotes: 1

Pred
Pred

Reputation: 9042

So your structure is: public_html/composer/composer.phar

If so, then either navigate into the composer folder (cd public_html/composer), then issue the ./composer.phar or php ./composer.phar command.

You can excute it using relative/absolute paths (./public_html/composer/composer.phar or /srv/www/mysite/whatever/public_html/composer/composer.phar)

Please note, that you have to execute composer from the folder where your composer.json file is located.

In all cases you have to have access to the folder and the file itself.

Upvotes: 0

Related Questions