Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8949517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:14:12+00:00 2026-06-15T13:14:12+00:00

I need to run composer.phar update from a web controller. I can run all

  • 0

I need to run composer.phar update from a web controller.

I can run all kinds of regular commands in this way (ls, cp, etc) but when I invoke the phar file I get empty output.

The code I have looks like this:

class Maintenance_Controller
{
    public function do_maintenance()
    {
        echo exec("/usr/bin/env php composer.phar", $out, $ret);
        var_dump($out); // outputs -> array()
        var_dump($ret); // outputs -> int(127)
    }
}

127 indicates a bad path, but I am sure I’m in the right directory.

Also, this works when using a php_cli wrapper, so maybe it has to do with the www-data user? chmod 777 does not help, and I hate to do that anyway.

I have also used passthru(), system() and the backtic syntax. I am unable to get to the reason this doesn’t work. I can’t seem to interrogate the stderr or stdout from the exec() call beyond the 127 code.

Obvious Question:

What am I doing wrong?

Better Question:

Is there a better way to interrogate and execute .phar files from within a script?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:14:14+00:00Added an answer on June 15, 2026 at 1:14 pm

    UPDATE:

    From this question:

    Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command.

    Try using exec('php composer.phar', $out, $ret); and see if that works. You might also need to use the full path to php if its in a non-standard location which you can probably get from which php.


    Im not sure why you are using passthru here. I would use exec for better handling.
    Id use exec here instead of passthru

    class Maintenance_Controller
    {
    
        public function do_maintenance()
        {
            exec("composer.phar update", $out, $ret);
            if(!$ret) {
                // handle success
            } else {
               // handle error
            }
    
        }
    }
    

    This way you have all the output by line in $out as well as the shell return val (0 if ok, > 0 if not). If you wanna get really fancy you can loop over $out and scan for the errors and then build and exception to throw.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to run an external application from within my Java code. I can
I need run all tests from my multimodule project using IDE. Like I do
I need run ts:reindex when smth add in model or destroy from model. How
I need to run two ffmpeg commands, one after the other i.e., wait until
I need to run some classic ASP locally before deployment to a legacy web
This is my problem: I need run some code every time I open a
OK, this should be brainlessly trivial, yet I can't manage to run. MS Access.
we need run one function periodically in Java web application . How to call
I need run a system call to run a .app file from java. Any
I need run tornado web server in a random port. Usually if a socket

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.