V
V
Vladislav2016-03-29 12:34:08
PHP
Vladislav, 2016-03-29 12:34:08

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();

Made a link to the file and put it in /usr/local/bin, called depman.
I try to run "depman" in the console and for some reason I get the error ": No such file or directory". And there is phpunit, which works on the same principle and everything starts up fine. What could be the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladislav, 2016-03-30
@MrBikus

It's all about CRLF line terminators

A
Alexey Ukolov, 2016-03-29
@alexey-m-ukolov

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.

A
Andrey, 2016-03-29
@GhOsT_MZ

Launch rights set?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question