There are many reasons why one might run into this error and thus a good checklist of what to check first helps considerably.
Let’s consider that we are troubleshooting the following line:
require "/path/to/file"
Checklist
1. Check the file path for typos
- either check manually (by visually checking the path)
-
or move whatever is called by
require*orinclude*to its own variable, echo it, copy it, and try accessing it from a terminal:$path = "/path/to/file"; echo "Path : $path"; require "$path";Then, in a terminal:
cat <file path pasted>
2. Check that the file path is correct regarding relative vs absolute path considerations
- if it is starting by a forward slash «/» then it is not referring to the root of your website’s folder (the document root), but to the root of your server.
- for example, your website’s directory might be
/users/tony/htdocs
- for example, your website’s directory might be
- if it is not starting by a forward slash then it is either relying on the include path (see below) or the path is relative. If it is relative, then PHP will calculate relatively to the path of the current working directory.
- thus, not relative to the path of your web site’s root, or to the file where you are typing
- for that reason, always use absolute file paths
Best practices :
In order to make your script robust in case you move things around, while still generating an absolute path at runtime, you have 2 options :
- use
require __DIR__ . "/relative/path/from/current/file". The__DIR__magic constant returns the directory of the current file. -
define a
SITE_ROOTconstant yourself :- at the root of your web site’s directory, create a file, e.g.
config.php -
in
config.php, writedefine('SITE_ROOT', __DIR__); -
in every file where you want to reference the site root folder, include
config.php, and then use theSITE_ROOTconstant wherever you like :require_once __DIR__."/../config.php"; ... require_once SITE_ROOT."/other/file.php";
- at the root of your web site’s directory, create a file, e.g.
These 2 practices also make your application more portable because it does not rely on ini settings like the include path.
3. Check your include path
Another way to include files, neither relatively nor purely absolutely, is to rely on the include path. This is often the case for libraries or frameworks such as the Zend framework.
Such an inclusion will look like this :
include "Zend/Mail/Protocol/Imap.php"
In that case, you will want to make sure that the folder where «Zend» is, is part of the include path.
You can check the include path with :
echo get_include_path();
You can add a folder to it with :
set_include_path(get_include_path().":"."/path/to/new/folder");
4. Check that your server has access to that file
It might be that all together, the user running the server process (Apache or PHP) simply doesn’t have permission to read from or write to that file.
To check under what user the server is running you can use posix_getpwuid :
$user = posix_getpwuid(posix_geteuid());
var_dump($user);
To find out the permissions on the file, type the following command in the terminal:
ls -l <path/to/file>
and look at permission symbolic notation
5. Check PHP settings
If none of the above worked, then the issue is probably that some PHP settings forbid it to access that file.
Three settings could be relevant :
- open_basedir
- If this is set PHP won’t be able to access any file outside of the specified directory (not even through a symbolic link).
- However, the default behavior is for it not to be set in which case there is no restriction
- This can be checked by either calling
phpinfo()or by usingini_get("open_basedir") - You can change the setting either by editing your php.ini file or your httpd.conf file
- safe mode
- if this is turned on restrictions might apply. However, this has been removed in PHP 5.4. If you are still on a version that supports safe mode upgrade to a PHP version that is still being supported.
- allow_url_fopen and allow_url_include
- this applies only to including or opening files through a network process such as http:// not when trying to include files on the local file system
- this can be checked with
ini_get("allow_url_include")and set withini_set("allow_url_include", "1")
Corner cases
If none of the above enabled to diagnose the problem, here are some special situations that could happen :
1. The inclusion of library relying on the include path
It can happen that you include a library, for example, the Zend framework, using a relative or absolute path. For example :
require "/usr/share/php/libzend-framework-php/Zend/Mail/Protocol/Imap.php"
But then you still get the same kind of error.
This could happen because the file that you have (successfully) included, has itself an include statement for another file, and that second include statement assumes that you have added the path of that library to the include path.
For example, the Zend framework file mentioned before could have the following include :
include "Zend/Mail/Protocol/Exception.php"
which is neither an inclusion by relative path, nor by absolute path. It is assuming that the Zend framework directory has been added to the include path.
In such a case, the only practical solution is to add the directory to your include path.
2. SELinux
If you are running Security-Enhanced Linux, then it might be the reason for the problem, by denying access to the file from the server.
To check whether SELinux is enabled on your system, run the sestatus command in a terminal. If the command does not exist, then SELinux is not on your system. If it does exist, then it should tell you whether it is enforced or not.
To check whether SELinux policies are the reason for the problem, you can try turning it off temporarily. However be CAREFUL, since this will disable protection entirely. Do not do this on your production server.
setenforce 0
If you no longer have the problem with SELinux turned off, then this is the root cause.
To solve it, you will have to configure SELinux accordingly.
The following context types will be necessary :
httpd_sys_content_tfor files that you want your server to be able to readhttpd_sys_rw_content_tfor files on which you want read and write accesshttpd_log_tfor log fileshttpd_cache_tfor the cache directory
For example, to assign the httpd_sys_content_t context type to your website root directory, run :
semanage fcontext -a -t httpd_sys_content_t "/path/to/root(/.*)?"
restorecon -Rv /path/to/root
If your file is in a home directory, you will also need to turn on the httpd_enable_homedirs boolean :
setsebool -P httpd_enable_homedirs 1
In any case, there could be a variety of reasons why SELinux would deny access to a file, depending on your policies. So you will need to enquire into that. Here is a tutorial specifically on configuring SELinux for a web server.
3. Symfony
If you are using Symfony, and experiencing this error when uploading to a server, then it can be that the app’s cache hasn’t been reset, either because app/cache has been uploaded, or that cache hasn’t been cleared.
You can test and fix this by running the following console command:
cache:clear
4. Non ACSII characters inside Zip file
Apparently, this error can happen also upon calling zip->close() when some files inside the zip have non-ASCII characters in their filename, such as «é».
A potential solution is to wrap the file name in utf8_decode() before creating the target file.
Credits to Fran Cano for identifying and suggesting a solution to this issue
За последние 24 часа нас посетили 8863 программиста и 810 роботов. Сейчас ищут 320 программистов …
-

- С нами с:
- 28 янв 2014
- Сообщения:
- 10
- Симпатии:
- 0
Привет пхп.ру!
У меня проблема.
Я — владелец сайта. Сайт был написан для меня под заказ и для личных целей, то есть без авторизации там делать нечего совсем. И как следствие — мои познания в программировании сильно ограничены.Совершенно неожиданно сайт перестал функционировать как надо, вообще никаких изменений не делал — перестали выполняться задания в Cron.
Точнее, сам крон работает, и если руками пытаться выполнить задание — тоже успешно, но задание не выполняется в итоге, т.к. натыкается на следующую ошибку:-
[23-Jan-2014 22:06:30 Europe/Moscow] PHP Warning: include_once(./include/basePliginClass.php) [function.include-once]: failed to open stream: No such file or directory in /home/cp***/public_html/plugins/copypost.php on line 3
-
[23-Jan-2014 22:06:30 Europe/Moscow] PHP Warning: include_once() [function.include]: Failed opening ‘./include/basePliginClass.php’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/cp***/public_html/plugins/copypost.php on line 3
-
[23-Jan-2014 22:06:30 Europe/Moscow] PHP Warning: include_once(./include/function.php) [function.include-once]: failed to open stream: No such file or directory in /home/cp***/public_html/plugins/copypost.php on line 4
-
[23-Jan-2014 22:06:30 Europe/Moscow] PHP Warning: include_once() [function.include]: Failed opening ‘./include/function.php’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/cp***/public_html/plugins/copypost.php on line 4
-
[23-Jan-2014 22:06:30 Europe/Moscow] PHP Fatal error: Class ‘basePluginClass’ not found in /home/cp***/public_html/plugins/copypost.php on line 6
Звёздочками в /home/cp закрыл я, на всякий случай, дабы избежать лишнего внимания. Мало ли что.
Так вот, директорию эту я проверил — и ./include/basePliginClass.php и /home/cp***/public_html/plugins/copypost.php — файлы на месте, разрешения в порядке (стояли 644, попробовал 777 — никакого эффекта)
Попытался перезапустить апач, подключившись к хостингу через SSH (по данным, которые дал мне хостер), но там открывается jailshell и на этом я застреваю. Видимо, надо как-то подключиться через SSH серверу, установленному на хостинге, но я не представляю как это сделать.
Сейчас я в тупике, рассказал что знаю, надеюсь на вашу помощь.
Спасибо.
-

Команда форума
Модератор- С нами с:
- 18 мар 2010
- Сообщения:
- 32.415
- Симпатии:
- 1.768
да. стать админом. например, расскажите, как именно вы проверили путь
-

- С нами с:
- 28 янв 2014
- Сообщения:
- 10
- Симпатии:
- 0
Открыл в файл-менеджере данный путь и проверил наличие этого файла, больше никак не могу.
Если ваш вопрос касается точки перед путём — то проверял я в той директории, из которой выполняется сам php-скрипт (у меня это /home/cp***/public_html/) -

Команда форума
Модератор- С нами с:
- 18 мар 2010
- Сообщения:
- 32.415
- Симпатии:
- 1.768
А поиском этот файл найти можно? Он существует?
-

- С нами с:
- 28 янв 2014
- Сообщения:
- 10
- Симпатии:
- 0
Да, в файловом менеджере поиском находит в этой же директории
-

Команда форума
Модератор- С нами с:
- 18 мар 2010
- Сообщения:
- 32.415
- Симпатии:
- 1.768
На папку разрешения тоже 777 попробуй
-

- С нами с:
- 28 янв 2014
- Сообщения:
- 10
- Симпатии:
- 0
-

Команда форума
Модератор- С нами с:
- 18 мар 2010
- Сообщения:
- 32.415
- Симпатии:
- 1.768
странно чо
давай ищи админа, давай ему доступ. так через форум это всё решать нереально. ну по крайней мере у меня фантазия кончилась. осталось только отключить selinux, если он у вас есть, и вопрос, почему он включился, если это он.
-

- С нами с:
- 28 янв 2014
- Сообщения:
- 10
- Симпатии:
- 0
Жаль.
Спасибо за проявленное внимание к проблеме, пошел на фриланс проект создавать.
-

Команда форума
Модератор- С нами с:
- 18 мар 2010
- Сообщения:
- 32.415
- Симпатии:
- 1.768
-

- С нами с:
- 28 янв 2014
- Сообщения:
- 10
- Симпатии:
- 0
Дебиан, кажется. Но не могу быть уверен, где-то посмотреть можно?
-

Команда форума
Модератор- С нами с:
- 18 мар 2010
- Сообщения:
- 32.415
- Симпатии:
- 1.768
я не помню. почитайте как отключить selinux, отключите и попробуйте снова.
-
- С нами с:
- 28 янв 2014
- Сообщения:
- 10
- Симпатии:
- 0
-

Команда форума
Модератор- С нами с:
- 18 мар 2010
- Сообщения:
- 32.415
- Симпатии:
- 1.768
-

Команда форума
Модератор- С нами с:
- 18 мар 2010
- Сообщения:
- 32.415
- Симпатии:
- 1.768
если у вас проект комерческий — наймите админа и арендуйте VPS
Добавлено спустя 22 секунды:
php 5.5 на дворе, они только 5.3 поставили -

- С нами с:
- 28 янв 2014
- Сообщения:
- 10
- Симпатии:
- 0
Нет, не коммерческий, для личных целей просто работает.
-

Команда форума
Модератор- С нами с:
- 18 мар 2010
- Сообщения:
- 32.415
- Симпатии:
- 1.768
может хостинг сменить? это знакомые?
-

san4ez
Активный пользователь- С нами с:
- 13 авг 2016
- Сообщения:
- 331
- Симпатии:
- 47
возникла такая же ошибка, когда решил залить на хостинг… на локалке все работает. а там
Warning: include(/include/top.php): failed to open stream: No such file or directory in /home/u828830295/public_html/index.php on line 5Warning: include(): Failed opening ‘/include/top.php’ for inclusion (include_path=’.:/opt/php-7.0/pear’) in /home/u828830295/public_html/index.php on line 5
пробовал и полный путь, тогда еще дополнительно вылазила ошибка
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/u828830295/public_html/index.php on line 5 -

san4ez
Активный пользователь- С нами с:
- 13 авг 2016
- Сообщения:
- 331
- Симпатии:
- 47
мой косяк был… папка Include с большой буквы была создана
This blog post is all about how to handle errors from the PHP file_get_contents function, and others which work like it.
The file_get_contents function will read the contents of a file into a string. For example:
<?php
$text = file_get_contents("hello.txt");
echo $text;
You can try this out on the command-line like so:
$ echo "hello" > hello.txt
$ php test.php
hello
This function is widely used, but I’ve observed that error handling around it is often not quite right. I’ve fixed a few bugs involving incorrect I/O error handling recently, so here are my thoughts on how it should be done.
How file_get_contents fails
For legacy reasons, this function does not throw an exception when something goes wrong. Instead, it will both log a warning, and return false.
<?php
$filename = "not-a-real-file.txt";
$text = file_get_contents($filename);
echo $text;
Which looks like this when you run it:
$ php test.php
PHP Warning: file_get_contents(not-a-real-file.txt): failed to open stream: No such file or directory in test.php on line 3
PHP Stack trace:
PHP 1. {main}() test.php:0
PHP 2. file_get_contents() test.php:3
Warnings are not very useful on their own, because the code will continue on without the correct data.
Error handling in four steps
If anything goes wrong when you are reading a file, your code should be throwing some type of Exception which describes the problem. This allows developers to put a try {} catch {} around it, and avoids nasty surprises where invalid data is used later.
Step 1: Detect that the file was not read
Any call to file_get_contents should be immediately followed by a check for that false return value. This is how you know that there is a problem.
<?php
$filename = "not-a-real-file.txt";
$text = file_get_contents($filename);
if($text === false) {
throw new Exception("File was not loaded");
}
echo $text;
This now gives both a warning and an uncaught exception:
$ php test.php
PHP Warning: file_get_contents(not-a-real-file.txt): failed to open stream: No such file or directory in test.php on line 3
PHP Stack trace:
PHP 1. {main}() test.php:0
PHP 2. file_get_contents() test.php:3
PHP Fatal error: Uncaught Exception: File was not loaded in test.php:5
Stack trace:
#0 {main}
thrown in test.php on line 5
Step 2: Suppress the warning
Warnings are usually harmless, but there are several good reasons to suppress them:
- It ensures that you are not depending on a global error handler (or the absence of one) for correct behaviour.
- The warning might appear in the middle of the output, depending on
php.ini. - Warnings can produce a lot of noise in the logs
Use @ to silence any warnings from a function call.
<?php
$filename = "not-a-real-file.txt";
$text = @file_get_contents($filename);
if($text === false) {
throw new Exception("File was not loaded");
}
echo $text;
The output is now only the uncaught Exception:
$ php test.php
PHP Fatal error: Uncaught Exception: File was not loaded in test.php:5
Stack trace:
#0 {main}
thrown in test.php on line 5
Step 3: Get the reason for the failure
Unfortunately, we lost the “No such file or directory” message, which is pretty important information, which should go in the Exception. This information is retrieved from the old-style error_get_last method.
This function might just return empty data, so you should check that everything is set and non-empty before you try to use it.
<?php
$filename = "not-a-real-file.txt";
error_clear_last();
$text = @file_get_contents($filename);
if($text === false) {
$e = error_get_last();
$error = (isset($e) && isset($e['message']) && $e['message'] != "") ?
$e['message'] : "Check that the file exists and can be read.";
throw new Exception("File '$filename' was not loaded. $error");
}
echo $text;
This now embeds the failure reason directly in the message.
$ php test.php
PHP Fatal error: Uncaught Exception: File 'not-a-real-file.txt' was not loaded. file_get_contents(not-a-real-file.txt): failed to open stream: No such file or directory in test.php:9
Stack trace:
#0 {main}
thrown in test.php on line 9
Step 4: Add a fallback
The last time I introduced error_clear_last()/get_last_error() into a code-base, I learned out that HHVM does not have these functions.
Call to undefined function error_clear_last()
The fix for this is to write some wrapper code, to verify that each function exists.
<?php
$filename = 'not-a-real-file';
clearLastError();
$text = @file_get_contents($filename);
if ($text === false) {
$error = getLastErrorOrDefault("Check that the file exists and can be read.");
throw new Exception("Could not retrieve image data from '$filename'. $error");
}
echo $text;
/**
* Call error_clear_last() if it exists. This is dependent on which PHP runtime is used.
*/
function clearLastError()
{
if (function_exists('error_clear_last')) {
error_clear_last();
}
}
/**
* Retrieve the message from error_get_last() if possible. This is very useful for debugging, but it will not
* always exist or return anything useful.
*/
function getLastErrorOrDefault(string $default)
{
if (function_exists('error_clear_last')) {
$e = error_get_last();
if (isset($e) && isset($e['message']) && $e['message'] != "") {
return $e['message'];
}
}
return $default;
}
This does the same thing as before, but without breaking other PHP runtimes.
$ php test.php
PHP Fatal error: Uncaught Exception: Could not retrieve image data from 'not-a-real-file'. file_get_contents(not-a-real-file): failed to open stream: No such file or directory in test.php:7
Stack trace:
#0 {main}
thrown in test.php on line 7
Since HHVM is dropping support for PHP, I expect that this last step will soon become unnecessary.
How not to handle errors
Some applications put a series of checks before each I/O operation, and then simply perform the operation with no error checking. An example of this would be:
<?php
$filename = "not-a-real-file.txt";
// Check everything!
if(!file_exists($filename)) {
throw new Exception("$filename does not exist");
}
if(!is_file($filename)) {
throw new Exception("$filename is not a file");
}
if(!is_readable($filename)) {
throw new Exception("$filename cannot be read");
}
// Assume that nothing can possibly go wrong..
$text = @file_get_contents($filename);
echo $text;
You could probably make a reasonable-sounding argument that checks are a good idea, but I consider them to be misguided:
- If you skip any actual error handling, then your code is going to fail in more surprising ways when you encounter an I/O problem that could not be detected.
- If you do perform correct error handling as well, then the extra checks add nothing other than more branches to test.
Lastly, beware of false positives. For example, the above snippet will reject HTTP URL’s, which are perfectly valid for file_get_contents.
Conclusion
Most PHP code now uses try/catch/finally blocks to handle problems, but the ecosystem really values backwards compatibility, so existing functions are rarely changed.
The style of error reporting used in these I/O functions is by now a legacy quirk, and should be wrapped to consistently throw a useful Exception.
Вы видите ошибку “Failed to Open Stream” в WordPress? Эта ошибка, как правило, указывает на расположение скриптов, где произошла ошибка. Тем не менее, это довольно сложно для начинающих пользователей, чтобы понять ее. В этой статье мы покажем вам, как легко исправить в WordPress ошибку “Failed to Open Stream”.
Почему происходит ошибка “Failed to Open Stream”?
Перед тем, как попытаться исправить ошибку, было бы полезно понять, что заставляет выводить ошибку “Failed to Open Stream” в WordPress.
Эта ошибка возникает, когда WordPress не может загрузить файл, упомянутый в веб-коде. При возникновении этой ошибки, иногда WordPress продолжит загрузку сайта и только покажет предупреждающее сообщение, в то время как другой сайт на WordPress покажет фатальную ошибку и ничего не загрузится.
Фразировка сообщения будет отличаться в зависимости от того, где происходит ошибка в коде, и причина отказа. Это также даст вам подсказки о том, что должно быть исправлено.
Как правило, это сообщение будет выглядеть примерно так:
Warning: require(/home/website/wp-includes/load.php): failed to open stream: No such file or directory in /home/website/wp-settings.php on line 21 Fatal error: require(): Failed opening required ‘/home/website/wp-includes/load.php’ (include_path=’.:/usr/share/php/:/usr/share/php5/’) in /home/website/wp-settings.php on line 21
Вот еще один пример:
Last Error: 2018-05-11 15:55:23: (2) HTTP Error: Unable to connect: ‘fopen(compress.zlib://https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles?start-index=1): failed to open stream: operation failed’
Сказав это, давайте посмотрим на то, как диагностировать и исправить ошибку “Failed to Open Stream” в WordPress.
Исправление ошибки “Failed to Open Stream” в WordPress
Как мы уже упоминали ранее, ошибка может быть вызвана различными причинами, и сообщение об ошибке будет отличаться в зависимости от причины и местоположения файла, который вызывает ошибку.
В каждом экземпляре не удалось открыть потоковую фразу, за которой следует причина. Например, отказано в разрешении, нет такого файла или каталога, сбой операции и многое другое.
Теперь, если ваше сообщение об ошибке содержит ‘no such file or directory’, то вам нужно смотреть код, чтобы выяснить, какой файл упоминается в этой конкретной строке.
Если это файл плагина или темы, то это означает, что файлы плагина или темы были удалены или установлены неправильно. Просто деактивируйте и переустановите тему/плагин, о котором идет речь, чтобы исправить ошибку.
Тем не менее, также возможно, что WordPress не может найти файлы из-за отсутствия файла .htaccess в корневой папке. В этом случае вам нужно перейти на страницу Настройки » Постоянные ссылки в вашей админки в WordPress и просто нажать кнопку “Сохранить изменения”, чтобы восстановить файл .htaccess.

Если сообщение об ошибке сопровождается ‘Permission denied’, то это означает, что WordPress не имеет правильного разрешения на доступ к файлу или каталогу, на который ссылается в коде.
Чтобы это исправить, вам нужно проверить разрешения на файлы икаталоги в WordPress и исправить их в случае необходимости.
Наконец, некоторые плагины в WordPress загружают скрипты из сторонних источников, таких как Google Analytics, Facebook API,, Google Maps и других API третьих сторон.
Некоторым из этих API, может потребоваться аутентификация или может быть изменен способ к которым разработчики могут получить доступ. Сбой аутентификации или неправильный метод доступа приведет WordPress не в состоянии открыть необходимые файлы.
Чтобы это исправить, вам нужно будет связаться с автором плагина для поддержки. Они должны в состоянии помочь вам исправить ошибку.
Если ни один из этих советов не поможет устранить проблему, то выполните действия, описанные в нашем руководстве поиска и устранения неисправностей в Worpdress . Этот шаг за шагом руководство поможет вам определить проблему, так что вы можете легко найти решение.
Мы надеемся, что эта статья помогла вам исправить ошибку “Failed to Open Stream” в WordPress. Вы также можете добавить список 25 наиболее распространенных ошибок в WordPress и как их исправить.
Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.
Yeah, same problem @weierophinney. Here’s the full set of steps I’ve performed:
# Get PHP version info $ php -v PHP 7.0.33 (cli) (built: May 20 2012 07:00:00) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies # Get Composer version info $ composer ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ / __ `__ / __ / __ / ___/ _ / ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / ____/____/_/ /_/ /_/ .___/____/____/___/_/ /_/ Composer version 1.10.10 2020-08-03 11:35:19 # Created an empty .env file. # Created an empty modules/ directory # Added a composer.json with the specified contents # Added test.php file with the specified contents # Run `composer install` $ composer install Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 91 installs, 0 updates, 0 removals - Installing yiisoft/yii2-composer (2.0.10): Loading from cache - Installing craftcms/plugin-installer (1.5.5): Loading from cache - Installing laminas/laminas-zendframework-bridge (1.1.0): Loading from cache - Installing laminas/laminas-stdlib (3.2.1): Loading from cache - Installing laminas/laminas-escaper (2.6.1): Loading from cache - Installing laminas/laminas-feed (2.12.3): Loading from cache - Installing symfony/polyfill-php72 (v1.18.1): Loading from cache - Installing paragonie/random_compat (v9.99.99): Loading from cache - Installing symfony/polyfill-php70 (v1.18.1): Loading from cache - Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache - Installing symfony/polyfill-intl-idn (v1.18.1): Loading from cache - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache - Installing symfony/polyfill-iconv (v1.18.1): Loading from cache - Installing doctrine/lexer (1.0.2): Loading from cache - Installing egulias/email-validator (2.1.20): Loading from cache - Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache - Installing craftcms/cms (3.4.0): Loading from cache - Installing ezyang/htmlpurifier (v4.13.0): Loading from cache - Installing cebe/markdown (1.2.1): Loading from cache - Installing yiisoft/yii2 (2.0.32): Loading from cache - Installing yiisoft/yii2-swiftmailer (2.1.2): Loading from cache - Installing symfony/var-dumper (v3.3.6): Loading from cache - Installing nikic/php-parser (v4.9.1): Loading from cache - Installing psr/container (1.0.0): Loading from cache - Installing psr/log (1.1.3): Loading from cache - Installing symfony/debug (v3.3.6): Loading from cache - Installing symfony/console (v3.3.6): Loading from cache - Installing dnoegel/php-xdg-base-dir (v0.1.1): Loading from cache - Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache - Installing symfony/polyfill-ctype (v1.18.1): Loading from cache - Installing psy/psysh (v0.10.4): Loading from cache - Installing yiisoft/yii2-shell (2.0.4): Loading from cache - Installing symfony/process (v3.3.6): Loading from cache - Installing yiisoft/yii2-queue (2.3.0): Loading from cache - Installing opis/closure (3.5.7): Loading from cache - Installing yiisoft/yii2-debug (2.1.13): Loading from cache - Installing yii2tech/ar-softdelete (1.0.4): Loading from cache - Installing webonyx/graphql-php (v0.12.6): Loading from cache - Installing voku/email-check (3.0.2): Loading from cache - Installing true/punycode (v2.1.1): Loading from cache - Installing voku/portable-ascii (1.5.3): Loading from cache - Installing voku/portable-utf8 (5.4.47): Loading from cache - Installing voku/anti-xss (4.1.28): Loading from cache - Installing voku/stop-words (2.0.1): Loading from cache - Installing voku/urlify (4.1.1): Loading from cache - Installing webmozart/assert (1.9.1): Loading from cache - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache - Installing phpdocumentor/type-resolver (0.5.1): Loading from cache - Installing phpdocumentor/reflection-docblock (4.3.4): Loading from cache - Installing voku/arrayy (5.15.0): Loading from cache - Installing voku/stringy (5.1.1): Loading from cache - Installing twig/twig (v2.12.5): Loading from cache - Installing symfony/yaml (v3.3.6): Loading from cache - Installing seld/cli-prompt (1.0.3): Loading from cache - Installing pixelandtonic/imagine (1.2.2.1): Loading from cache - Installing tubalmartin/cssmin (v4.1.1): Loading from cache - Installing pimple/pimple (v3.2.3): Loading from cache - Installing mrclay/props-dic (3.0.0): Loading from cache - Installing container-interop/container-interop (1.2.0): Downloading (100%) - Installing mrclay/jsmin-php (2.4.0): Loading from cache - Installing monolog/monolog (1.25.5): Loading from cache - Installing marcusschwarz/lesserphp (v0.5.4): Loading from cache - Installing intervention/httpauth (2.1.0): Loading from cache - Installing mrclay/minify (3.0.10): Loading from cache - Installing mikehaertl/php-shellcommand (1.6.2): Loading from cache - Installing psr/http-message (1.0.1): Loading from cache - Installing ralouphie/getallheaders (3.0.3): Loading from cache - Installing guzzlehttp/psr7 (1.6.1): Loading from cache - Installing guzzlehttp/promises (v1.3.1): Loading from cache - Installing guzzlehttp/guzzle (6.5.5): Loading from cache - Installing league/oauth2-client (2.5.0): Loading from cache - Installing league/flysystem (1.0.70): Loading from cache - Installing enshrined/svg-sanitize (0.13.3): Loading from cache - Installing elvanto/litemoji (1.4.4): Loading from cache - Installing creocoder/yii2-nested-sets (0.9.0): Loading from cache - Installing craftcms/server-check (1.1.9): Loading from cache - Installing craftcms/oauth2-craftid (1.0.0.1): Loading from cache - Installing seld/phar-utils (1.1.1): Loading from cache - Installing symfony/filesystem (v3.3.6): Loading from cache - Installing symfony/finder (v3.3.6): Loading from cache - Installing seld/jsonlint (1.8.2): Loading from cache - Installing composer/spdx-licenses (1.5.4): Loading from cache - Installing composer/semver (1.7.0): Downloading (100%) - Installing composer/ca-bundle (1.2.8): Loading from cache - Installing justinrainbow/json-schema (5.2.10): Loading from cache - Installing composer/composer (1.6.3): Loading from cache - Installing laminas/laminas-validator (2.12.2): Downloading (100%) - Installing laminas/laminas-uri (2.7.1): Downloading (100%) - Installing laminas/laminas-loader (2.6.1): Downloading (100%) - Installing laminas/laminas-http (2.13.0): Downloading (100%) - Installing vlucas/phpdotenv (v2.6.6): Loading from cache laminas/laminas-feed suggests installing laminas/laminas-cache (LaminasCache component, for optionally caching feeds between requests) laminas/laminas-feed suggests installing laminas/laminas-db (LaminasDb component, for use with PubSubHubbub) laminas/laminas-feed suggests installing laminas/laminas-servicemanager (LaminasServiceManager component, for easily extending ExtensionManager implementations) paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.) craftcms/cms suggests installing ext-imagick (Adds support for more image processing formats and options.) symfony/var-dumper suggests installing ext-symfony_debug symfony/console suggests installing symfony/event-dispatcher psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.) psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.) yiisoft/yii2-queue suggests installing yiisoft/yii2-redis (Need for Redis queue.) yiisoft/yii2-queue suggests installing pda/pheanstalk (Need for Beanstalk queue.) yiisoft/yii2-queue suggests installing php-amqplib/php-amqplib (Need for AMQP queue.) yiisoft/yii2-queue suggests installing enqueue/amqp-lib (Need for AMQP interop queue.) yiisoft/yii2-queue suggests installing ext-gearman (Need for Gearman queue.) yiisoft/yii2-queue suggests installing aws/aws-sdk-php (Need for aws SQS.) yiisoft/yii2-queue suggests installing enqueue/stomp (Need for Stomp queue.) webonyx/graphql-php suggests installing react/promise (To leverage async resolving on React PHP platform) pixelandtonic/imagine suggests installing ext-imagick (to use the Imagick implementation) pixelandtonic/imagine suggests installing ext-gmagick (to use the Gmagick implementation) monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server) monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server) monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server) monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server) monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib) monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required)) monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server) monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver) monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB) monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar) monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome) mrclay/minify suggests installing firephp/firephp-core (Use FirePHP for Log messages) mrclay/minify suggests installing meenie/javascript-packer (Keep track of the Packer PHP port using Composer) guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses) league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem) league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files) league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage) league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage) league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2) league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3) league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage) league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications) league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching) league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib) league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter) laminas/laminas-validator suggests installing laminas/laminas-db (LaminasDb component, required by the (No)RecordExists validator) laminas/laminas-validator suggests installing laminas/laminas-filter (LaminasFilter component, required by the Digits validator) laminas/laminas-validator suggests installing laminas/laminas-i18n (LaminasI18n component to allow translation of validation error messages) laminas/laminas-validator suggests installing laminas/laminas-i18n-resources (Translations of validator messages) laminas/laminas-validator suggests installing laminas/laminas-math (LaminasMath component, required by the Csrf validator) laminas/laminas-validator suggests installing laminas/laminas-servicemanager (LaminasServiceManager component to allow using the ValidatorPluginManager and validator chains) laminas/laminas-validator suggests installing laminas/laminas-session (LaminasSession component, ^2.8; required by the Csrf validator) laminas/laminas-http suggests installing paragonie/certainty (For automated management of cacert.pem) Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead. Writing lock file Generating optimized autoload files 23 packages you are using are looking for funding. Use the `composer fund` command to find out more! # Run `php test.php` $ php test.php PHP Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5 Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5 PHP Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5 Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5
Then I tried using an earlier version of Craft that didn’t have laminas-feed but I’m still including laminas/laminas-http, and got the same error
# Remove composer.lock and vendor/ $ rm -rf vendor/ composer.lock # Change Craft to version 3.3.20.1 (before including laminas-feed) in composer.json # Run `composer install` $ composer install Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 78 installs, 0 updates, 0 removals - Installing yiisoft/yii2-composer (2.0.10): Loading from cache - Installing craftcms/plugin-installer (1.5.5): Loading from cache - Installing laminas/laminas-zendframework-bridge (1.1.0): Loading from cache - Installing laminas/laminas-stdlib (3.2.1): Loading from cache - Installing laminas/laminas-escaper (2.6.1): Loading from cache - Installing zendframework/zend-feed (2.12.0): Loading from cache - Installing symfony/polyfill-php72 (v1.18.1): Loading from cache - Installing paragonie/random_compat (v9.99.99): Loading from cache - Installing symfony/polyfill-php70 (v1.18.1): Loading from cache - Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache - Installing symfony/polyfill-intl-idn (v1.18.1): Loading from cache - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache - Installing symfony/polyfill-iconv (v1.18.1): Loading from cache - Installing doctrine/lexer (1.0.2): Loading from cache - Installing egulias/email-validator (2.1.20): Loading from cache - Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache - Installing craftcms/cms (3.3.20.1): Loading from cache - Installing ezyang/htmlpurifier (v4.13.0): Loading from cache - Installing cebe/markdown (1.2.1): Loading from cache - Installing yiisoft/yii2 (2.0.31): Loading from cache - Installing yiisoft/yii2-swiftmailer (2.1.2): Loading from cache - Installing symfony/process (v3.3.6): Loading from cache - Installing yiisoft/yii2-queue (2.1.0): Loading from cache - Installing opis/closure (3.5.7): Loading from cache - Installing yiisoft/yii2-debug (2.1.13): Loading from cache - Installing yii2tech/ar-softdelete (1.0.4): Loading from cache - Installing webonyx/graphql-php (v0.12.6): Loading from cache - Installing voku/email-check (3.0.2): Loading from cache - Installing true/punycode (v2.1.1): Loading from cache - Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache - Installing voku/portable-ascii (1.5.3): Loading from cache - Installing voku/portable-utf8 (5.4.47): Loading from cache - Installing voku/anti-xss (4.1.28): Loading from cache - Installing voku/stop-words (2.0.1): Loading from cache - Installing voku/urlify (4.1.1): Loading from cache - Installing symfony/polyfill-ctype (v1.18.1): Loading from cache - Installing webmozart/assert (1.9.1): Loading from cache - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache - Installing phpdocumentor/type-resolver (0.5.1): Loading from cache - Installing phpdocumentor/reflection-docblock (4.3.4): Loading from cache - Installing voku/arrayy (5.15.0): Loading from cache - Installing voku/stringy (5.1.1): Loading from cache - Installing twig/twig (v2.12.5): Loading from cache - Installing symfony/yaml (v3.3.6): Loading from cache - Installing seld/cli-prompt (1.0.3): Loading from cache - Installing pixelandtonic/imagine (1.2.2.1): Loading from cache - Installing mikehaertl/php-shellcommand (1.6.2): Loading from cache - Installing psr/http-message (1.0.1): Loading from cache - Installing ralouphie/getallheaders (3.0.3): Loading from cache - Installing guzzlehttp/psr7 (1.6.1): Loading from cache - Installing guzzlehttp/promises (v1.3.1): Loading from cache - Installing guzzlehttp/guzzle (6.5.5): Loading from cache - Installing league/oauth2-client (2.5.0): Loading from cache - Installing league/flysystem (1.0.70): Loading from cache - Installing enshrined/svg-sanitize (0.13.3): Loading from cache - Installing elvanto/litemoji (1.4.4): Loading from cache - Installing creocoder/yii2-nested-sets (0.9.0): Loading from cache - Installing craftcms/server-check (1.1.9): Loading from cache - Installing craftcms/oauth2-craftid (1.0.0.1): Loading from cache - Installing psr/log (1.1.3): Loading from cache - Installing seld/phar-utils (1.1.1): Loading from cache - Installing symfony/filesystem (v3.3.6): Loading from cache - Installing symfony/finder (v3.3.6): Loading from cache - Installing psr/container (1.0.0): Loading from cache - Installing symfony/debug (v3.3.6): Loading from cache - Installing symfony/console (v3.3.6): Loading from cache - Installing seld/jsonlint (1.8.2): Loading from cache - Installing composer/spdx-licenses (1.5.4): Loading from cache - Installing composer/semver (1.7.0): Loading from cache - Installing composer/ca-bundle (1.2.8): Loading from cache - Installing justinrainbow/json-schema (5.2.10): Loading from cache - Installing composer/composer (1.6.3): Loading from cache - Installing container-interop/container-interop (1.2.0): Loading from cache - Installing laminas/laminas-validator (2.12.2): Loading from cache - Installing laminas/laminas-uri (2.7.1): Loading from cache - Installing laminas/laminas-loader (2.6.1): Loading from cache - Installing laminas/laminas-http (2.13.0): Loading from cache - Installing vlucas/phpdotenv (v2.6.6): Loading from cache zendframework/zend-feed suggests installing zendframework/zend-cache (ZendCache component, for optionally caching feeds between requests) zendframework/zend-feed suggests installing zendframework/zend-db (ZendDb component, for use with PubSubHubbub) zendframework/zend-feed suggests installing zendframework/zend-servicemanager (ZendServiceManager component, for easily extending ExtensionManager implementations) paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.) craftcms/cms suggests installing ext-imagick (Adds support for more image processing formats and options.) yiisoft/yii2-queue suggests installing yiisoft/yii2-redis (Need for Redis queue.) yiisoft/yii2-queue suggests installing pda/pheanstalk (Need for Beanstalk queue.) yiisoft/yii2-queue suggests installing php-amqplib/php-amqplib (Need for AMQP queue.) yiisoft/yii2-queue suggests installing enqueue/amqp-lib (Need for AMQP interop queue.) yiisoft/yii2-queue suggests installing ext-gearman (Need for Gearman queue.) yiisoft/yii2-queue suggests installing aws/aws-sdk-php (Need for aws SQS.) webonyx/graphql-php suggests installing react/promise (To leverage async resolving on React PHP platform) pixelandtonic/imagine suggests installing ext-imagick (to use the Imagick implementation) pixelandtonic/imagine suggests installing ext-gmagick (to use the Gmagick implementation) guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses) league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem) league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files) league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage) league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage) league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2) league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3) league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage) league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications) league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching) league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib) league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter) symfony/console suggests installing symfony/event-dispatcher laminas/laminas-validator suggests installing laminas/laminas-db (LaminasDb component, required by the (No)RecordExists validator) laminas/laminas-validator suggests installing laminas/laminas-filter (LaminasFilter component, required by the Digits validator) laminas/laminas-validator suggests installing laminas/laminas-i18n (LaminasI18n component to allow translation of validation error messages) laminas/laminas-validator suggests installing laminas/laminas-i18n-resources (Translations of validator messages) laminas/laminas-validator suggests installing laminas/laminas-math (LaminasMath component, required by the Csrf validator) laminas/laminas-validator suggests installing laminas/laminas-servicemanager (LaminasServiceManager component to allow using the ValidatorPluginManager and validator chains) laminas/laminas-validator suggests installing laminas/laminas-session (LaminasSession component, ^2.8; required by the Csrf validator) laminas/laminas-http suggests installing paragonie/certainty (For automated management of cacert.pem) Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead. Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead. Writing lock file Generating optimized autoload files 20 packages you are using are looking for funding. Use the `composer fund` command to find out more! # Run `php test.php` and get same error $ php test.php PHP Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5 Warning: require_once(//composer/autoload_real.php): failed to open stream: No such file or directory in /autoload.php on line 5 PHP Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5 Fatal error: require_once(): Failed opening required '//composer/autoload_real.php' (include_path='.:/opt/sp/php7.0/lib/php') in /autoload.php on line 5
Finally, I tried the same version of Craft, removed laminas/laminas-http, and only used the require './vendor/autoload.php'; in the test.php file and the error no longer shows up:
# Run `composer install` $ composer install Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 71 installs, 0 updates, 0 removals - Installing yiisoft/yii2-composer (2.0.10): Loading from cache - Installing craftcms/plugin-installer (1.5.5): Loading from cache - Installing zendframework/zend-stdlib (3.2.1): Loading from cache - Installing zendframework/zend-escaper (2.6.1): Loading from cache - Installing zendframework/zend-feed (2.12.0): Loading from cache - Installing symfony/polyfill-php72 (v1.18.1): Loading from cache - Installing paragonie/random_compat (v9.99.99): Loading from cache - Installing symfony/polyfill-php70 (v1.18.1): Loading from cache - Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache - Installing symfony/polyfill-intl-idn (v1.18.1): Loading from cache - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache - Installing symfony/polyfill-iconv (v1.18.1): Loading from cache - Installing doctrine/lexer (1.0.2): Loading from cache - Installing egulias/email-validator (2.1.20): Loading from cache - Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache - Installing craftcms/cms (3.3.20.1): Loading from cache - Installing ezyang/htmlpurifier (v4.13.0): Loading from cache - Installing cebe/markdown (1.2.1): Loading from cache - Installing yiisoft/yii2 (2.0.31): Loading from cache - Installing yiisoft/yii2-swiftmailer (2.1.2): Loading from cache - Installing symfony/process (v3.3.6): Loading from cache - Installing yiisoft/yii2-queue (2.1.0): Loading from cache - Installing opis/closure (3.5.7): Loading from cache - Installing yiisoft/yii2-debug (2.1.13): Loading from cache - Installing yii2tech/ar-softdelete (1.0.4): Loading from cache - Installing webonyx/graphql-php (v0.12.6): Loading from cache - Installing voku/email-check (3.0.2): Loading from cache - Installing true/punycode (v2.1.1): Loading from cache - Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache - Installing voku/portable-ascii (1.5.3): Loading from cache - Installing voku/portable-utf8 (5.4.47): Loading from cache - Installing voku/anti-xss (4.1.28): Loading from cache - Installing voku/stop-words (2.0.1): Loading from cache - Installing voku/urlify (4.1.1): Loading from cache - Installing symfony/polyfill-ctype (v1.18.1): Loading from cache - Installing webmozart/assert (1.9.1): Loading from cache - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache - Installing phpdocumentor/type-resolver (0.5.1): Loading from cache - Installing phpdocumentor/reflection-docblock (4.3.4): Loading from cache - Installing voku/arrayy (5.15.0): Loading from cache - Installing voku/stringy (5.1.1): Loading from cache - Installing twig/twig (v2.12.5): Loading from cache - Installing symfony/yaml (v3.3.6): Loading from cache - Installing seld/cli-prompt (1.0.3): Loading from cache - Installing pixelandtonic/imagine (1.2.2.1): Loading from cache - Installing mikehaertl/php-shellcommand (1.6.2): Loading from cache - Installing psr/http-message (1.0.1): Loading from cache - Installing ralouphie/getallheaders (3.0.3): Loading from cache - Installing guzzlehttp/psr7 (1.6.1): Loading from cache - Installing guzzlehttp/promises (v1.3.1): Loading from cache - Installing guzzlehttp/guzzle (6.5.5): Loading from cache - Installing league/oauth2-client (2.5.0): Loading from cache - Installing league/flysystem (1.0.70): Loading from cache - Installing enshrined/svg-sanitize (0.13.3): Loading from cache - Installing elvanto/litemoji (1.4.4): Loading from cache - Installing creocoder/yii2-nested-sets (0.9.0): Loading from cache - Installing craftcms/server-check (1.1.9): Loading from cache - Installing craftcms/oauth2-craftid (1.0.0.1): Loading from cache - Installing psr/log (1.1.3): Loading from cache - Installing seld/phar-utils (1.1.1): Loading from cache - Installing symfony/filesystem (v3.3.6): Loading from cache - Installing symfony/finder (v3.3.6): Loading from cache - Installing symfony/debug (v3.3.6): Loading from cache - Installing symfony/console (v3.3.6): Loading from cache - Installing seld/jsonlint (1.8.2): Loading from cache - Installing composer/spdx-licenses (1.5.4): Loading from cache - Installing composer/semver (1.7.0): Loading from cache - Installing composer/ca-bundle (1.2.8): Loading from cache - Installing justinrainbow/json-schema (5.2.10): Loading from cache - Installing composer/composer (1.6.3): Loading from cache - Installing vlucas/phpdotenv (v2.6.6): Loading from cache zendframework/zend-feed suggests installing zendframework/zend-cache (ZendCache component, for optionally caching feeds between requests) zendframework/zend-feed suggests installing zendframework/zend-db (ZendDb component, for use with PubSubHubbub) zendframework/zend-feed suggests installing zendframework/zend-http (ZendHttp for PubSubHubbub, and optionally for use with ZendFeedReader) zendframework/zend-feed suggests installing zendframework/zend-servicemanager (ZendServiceManager component, for easily extending ExtensionManager implementations) zendframework/zend-feed suggests installing zendframework/zend-validator (ZendValidator component, for validating email addresses used in Atom feeds and entries when using the Writer subcomponent) paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.) craftcms/cms suggests installing ext-imagick (Adds support for more image processing formats and options.) yiisoft/yii2-queue suggests installing yiisoft/yii2-redis (Need for Redis queue.) yiisoft/yii2-queue suggests installing pda/pheanstalk (Need for Beanstalk queue.) yiisoft/yii2-queue suggests installing php-amqplib/php-amqplib (Need for AMQP queue.) yiisoft/yii2-queue suggests installing enqueue/amqp-lib (Need for AMQP interop queue.) yiisoft/yii2-queue suggests installing ext-gearman (Need for Gearman queue.) yiisoft/yii2-queue suggests installing aws/aws-sdk-php (Need for aws SQS.) webonyx/graphql-php suggests installing react/promise (To leverage async resolving on React PHP platform) pixelandtonic/imagine suggests installing ext-imagick (to use the Imagick implementation) pixelandtonic/imagine suggests installing ext-gmagick (to use the Gmagick implementation) guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses) league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem) league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files) league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage) league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage) league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2) league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3) league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage) league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications) league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching) league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib) league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter) symfony/console suggests installing symfony/event-dispatcher Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead. Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead. Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead. Writing lock file Generating optimized autoload files 18 packages you are using are looking for funding. Use the `composer fund` command to find out more! # Run `php test.php` with success and showing now output $ php test.php
You might get the following error while trying to run Laravel for the first time.
Warning: require(/var/www/laravel/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/laravel/bootstrap/autoload.php on line 17
Fatal error: require(): Failed opening required ‘/var/www/laravel/bootstrap/../vendor/autoload.php’ (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/laravel/bootstrap/autoload.php on line 17
Problem Scenario:
This error generally occurs when you download/clone Laravel from Github and then you put it in your web server. Then, you try to access it through your browser (e.g. http://localhost/laravel/public).
Cause:
Though you have downloaded the Laravel code and put it in your server, there’s still missing dependencies (library files/codes) in the code. The missing dependencies should be installed in order to make Laravel run properly.
Solution:
To solve this error, you need to install the missing dependencies via composer. Composer is a dependency manager tool for PHP. If you don’t have composer installed in your system then you need to install it first. You can get/download composer from here: https://getcomposer.org.
Once you have installed composer on your system/computer, then you need to follow the steps below to install the missing dependencies:
- Open terminal or command prompt
- Go to your Laravel directory
- For example, in Ubuntu Linux the web root is /var/www/, in Windows if you install Wampp in C: Drive then the web root will be C://wampp/www
- Suppose, you downloaded and copied the Laravel files in directory named ‘laravel’
- Then, your Laravel directory on your web server in Ubuntu will be /var/www/laravel
- You can go to that directory by running the following command on terminal:
cd /var/www/laravel
- Run the following command
composer install
- This will install the required dependencies to run Laravel. It will take some time to install all the dependencies.
- Now, you should be able to access Laravel properly without any error, e.g. `http://localhost/laravel/public`
If you already have run composer install command and still getting the error, then you can try running the following command:
composer update
Note: If you are on Linux then you should also set write permission to bootstrap/cache and storage directories.
Here’s the command to do so:
sudo chmod -R 777 bootstrap/cache storage
Alternatively, the better way to create laravel project / install Laravel will be directly through composer. Instead of downloading/cloning Laravel from GitHub, you can run the following composer command in terminal/command-prompt:
- Go to your web server root (in Ubuntu, it’s /var/www/)
- Run the following command in terminal:
composer create-project laravel/laravel name-of-your-project
- This will create a directory with
name-of-your-projectand install Laravel files in it - This will also install all the required dependencies to run Laravel
- Then, you can simply browse `http://localhost/name-of-your-project/public` to access Laravel
Hope this helps. Thanks.