Answer the question
In order to leave comments, you need to log in
Why, when I run a script written in php from the command line, I get the answer ": No such file or directory"?
I wrote a script using the symfony component console, added #!/usr/bin/env php to the beginning of the file, as a result it turned out:
#!/usr/bin/env php
<?php
/**
* Created by PhpStorm.
* User: mrbik_000
* Date: 21.03.2016
* Time: 12:16
*/
error_reporting(0);
require "vendor/autoload.php";
use Symfony\Component\Finder\Finder;
use Symfony\Component\Console\Application;
use DeployManager\ListCommand;
$application = new Application();
$application->add(new ListCommand());
$output = $application->run();
Answer the question
In order to leave comments, you need to log in
require __DIR__ . "/vendor/autoload.php";
In your code, the script tries to find the vendor folder in the folder you are calling it from. Of course, it may not be there, so you need to pin the search not to the current working directory, but to the script directory using the __DIR__ constant.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question