I know there are already a lot of topics and solutions about this error, but nothing seems to work for me.
So, I'm having a Laravel project created with composer. To run the project I use the "php artisan serve" command. In my project, I'm using the SerpWoW API, an easy to use API for Google images etc. since yesterday, installed with composter (composer require serpwow/google-search-results). But since then I'm having trouble with vendor/autoload.php.
In one of SerpWoW's config files, there's a line:
require "vendor/autoload.php";
Like this, I'm able to run the serve command and to start the project. Unfortunately, my views (.blade.php files) are giving the error: Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in (path to that config file)
I then changed
require "vendor/autoload.php";
to
require "../vendor/autoload.php";
and my views came back. Problem solved I thought. But now I'm getting the error when I try to run the serve command to run my project. Same error pointing to same file and so unable to start my project. When I reverse my solution I'm able again to start my project but my views are giving the error again (I know, it's complicated). What I'm doing now is starting my project with original path, then change the path in the file, save it and so I'm able to see my views.
I've already run composer install and composer update for a few times in my project directory but that didn't help. Hope someone knows a solution for this.
It looks like the package solved the issue in the master branch, see the comparison between the current 0.2.4 and master:
- require "vendor/autoload.php";
+ require __DIR__ . '/../../../vendor/autoload.php';
Since you should not modify any files in the vendor folder, you could instead require the latest development version until this change is tagged with a proper version number or maybe ask the maintainer to tag a release with this change:
composer require serpwow/google-search-results:"#dev-master"
I am trying to run a laravel app in my local system. I have followed the https://gist.github.com/hootlex/da59b91c628a6688ceb1 link. I run the command php artisan serve command, and when I browse it, then produces the error
PHP Fatal error: Uncaught Exception: Unable to locate Mix file: /css/vendor.css. Please check your webpack.mix.js output paths and try again. in /var/www/html/laravel-app/app/helpers.php:439
In the specified line of helpers.php, it has
if (! isset($manifest[$path])) {
throw new Exception(
"Unable to locate Mix file: {$path}. Please check your ".
'webpack.mix.js output paths and try again.'
);
}
public/mix-manifest.json
{
"/mix.js": "/mix.js"
}
I couldn't sort it out. Please help. Thanks
The blade file you're loading obviously has mix('/css/vendor.css') call. You either comment out this line(s) or install npm then build your assets.
Your manifest file doesn't have /css/vendor.css but if you check your blade files (views) you'll see you are calling mix('/css/vendor.css'). So if you find and comment out this line(s) your problem will be solved.
Ideally, mix() is used for loading assets that were built by webpack. It will then take care of the versioning string for you. How mix can be used is detailed in the documentation. I will refrain myself from discussing that here.
You've built your assets by running npm run dev or similar commands. And then the manifest file doesn't contain those assets mapping. And your public directory doesn't have those assets as well. Then it's safe to assume that you can remove those mix calls from your blade (views) files.
If you have the assets built in your public directory then you can load those assets by assets function.
Lastly, you should know your assets first, before loading them to your site. I get the notion that you don't have any clue where those assets came from, so you shouldn't load them in the first place.
This happened with me and after spending quite some time and effort, I did manage to figure out what was happening and how to fix it.
Here's what happens:
You update your webpack.mix.js file with the destination where you wish to publish your compiled JS and CSS files respectively.
mix.js('resources/js/app.js', 'public/js').vue();
Mix compiles and stores the hence generated CSS and JS files within their respective destination folders when you run npm run dev or npm run watch.
laravel-app (Your laravel app root folder)
\public
\css
\app.css
\js
\app.js
When you open the application in your browser with, say Valet, Laravel spits out the following error message:
Unable to locate Mix file: /js/app.js
(or)
Unable to locate Mix file: /css/app.css
Something worth noting on the Uncaught Exception screen though, is that Laravel by default attempts to look for the files at localhost:8080. Implied that Laravel is looking for the files respectively at:
localhost:8080\css\app.css
(and)
localhost:8080\js\app.js
Hence, if your hostname or port is anything other than localhost:8080, Laravel would not be able to find your files. For example, if you're using Valet, your default URL would become laravel-app.test where laravel-app is the name of your app's root folder.
But, there's a way to fix this. And it comes directly out to Laravel's documentation.
Solution (TL;DR)
In order to use a custom mix base URL, you would require to update your config\app.php file to add the following configuration value for setting the mix URL:
'mix_url' => env('MIX_ASSET_URL', 'localhost'),
With your mix_url config option set in your app.php file, you should now be able to manipulate it by adding the MIX_ASSET_URL key in your .env file and setting it to blank, so that it points to \public\js\app.js and \public\css\app.css respectively, within your project directory.
MIX_ASSET_URL=""
That solved it for me. Hope it does it for your too. Lemme know how it goes. Cheers!
Try running npm install and after that build the assets, either npm run dev or npm run watch , depends on what you are using.
In my case,
laravel 9
I should have changed the mix-manifest.json file
"/js/application.js": "/js/application.js",
"/js/admin.js": "/js/admin.js",
"/css/application.css": "/css/application.css",
"/css/admin.css":"/css/admin.css"
Delete package-lock.json.
Delete folder 'node_modules' and run 'npm install' to reinstall all modules.
Then run 'npm run watch' or 'npm run production'.
That helps me to fix that problem.
check the package.json file for the command to build the scripts and styles, normally you will have by default: npm run dev. Might happen that you will need to run:
npm rebuild node-sass
npm run dev or npm run watch
I changed my webpack.mix.js files and made these changes there and worked. Only define the specific path to public/js/app.js in webpack.mix.js
mix.js(
[
"resources/assets/js/jquery.js",
"resources/assets/js/popper.js",
"resources/js/app.js",
],
"public/js/app.js"
)
.autoload({
jquery: ["jquery", "jQuery", "$", "window.jQuery"],
Popper: ["popper", "Popper", "popper.js"],
popper: ["Popper", "popper.js"],
})
.vue()
.postCss("resources/css/app.css", "public/css", [])
.sass("resources/sass/app.scss", "public/css")
.disableNotifications(); // to disable notifications of building app;
In My case, I change
'debug' => false, to true
in the file app.config under config folder in my project to see log in my browser. Then when I run my project got error above like you. then I change to
'debug' => false again. It works.
I try to get this done from github.
https://github.com/binance-exchange/php-binance-api
I installed Xampp (latest version: 7.2.3) on a win 10 machine. Xampp is running. (at least not mysql, because it has an error while starting, but mysql is not needed).
I downloaded the files from github and puttet them into my htdocs in a new folder called "binance".
I downloaded the install-file for composer from here: https://getcomposer.org/doc/00-intro.md#installation-windows
Installed it and choosed the php.exe out of my xampp folder inside the installation-process.
Composer starts out of the console, and it works.
I put this command into the cmd:
php composer.phar require "jaggedsoft/php-binance-api #dev"
It installs some folders and files, but not into my project-directory. It downloads and installs it into "user/vendor/..." on my drive c.
Inside of the files downloaded from github, there is a file called:
php-binance-api-test.php
Inside this file, there are different lines like:
require 'vendor/autoload.php';
file_put_contents( getenv("HOME") . "/.config/jaggedsoft/php-binance-api.json" ,
I copied the whole vendor directory into my project directory, so he can find his files.
But he is not able to find ".config/jaggedsoft/" because there is no folder named .config.
There is also no file named php-binance-api.json only one called php-binance-api.php
If I try to access some of the sample file, like web_socket_chart.php in examples, he gives me an fatal error:
Fatal error: Uncaught Error: Class 'React\EventLoop\Factory' not found in
...
this might be a file inside of the php-folder of xampp, but how does he load it before to get the class nedded?
I think i messed up the installation of composer? or do I have to choose other place for the project inside of xampp?
What is composer even good for? I would be really thankful, if someone may try to get this run an tell me, what I have done wrong.
I just started out my journey in learning more about programming in PHP - PDO style. I've just installed PhpStorm on my PC to serve as IDE.
I'm now stuck at why PhpStorm can't identify where the included php file is. I did my research and I noticed that others also encountered the same problem when they first used PhpStorm.
I am getting
Warning: include(): Failed opening '../controller_admin.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\Users\Jordan\PhpstormProjects\cai\view\view_admin\admin_accountmanagement.php on line 6
It appears that the root of all included directories/file starts in C:\xampp\php\PEAR which appears to be the default since I'm using XAMPP. But in my case, I created my project folder in C:\Users\Jordan\PhpStormProjects\cai
I did my research and I found different suggestions and possible solutions.
Some of which are :
Editing of php.ini include path (which I didn't do because I want to fix it within PHPStorm instead of modifying the php.ini)
Setting the include path in PhpStorm's PHP Setting like so
Using set_include_path() method in index.php
Adding the project in C:\xampp\php\PEAR\projectfolderhere which limits my flexibility of putting the project folder somewhere else. (I don't like this solution)
My include statement:
<?php var_dump(get_include_path())?> //returns ".;C:\xampp\php\PEAR" in browser
<?php include('controller/controller_admin.php')?>
controller directory is C:\Users\Jordan\PhpStormProjects\cai\controller
I wonder why is it that even after adding the project's root folder directory to PhpStorm's Include Path settings it still can't reference or see the project folder and sub folders.
I want to integrate phpspec2 with CodeIgniter 2. I've succesfully installed phpspec using composer as described on phpspec website. Now I'd like to integrate it into my CodeIgniter 2 installation. I've found an article by AniDear on this subject and did everything as described. However when I run bin/phpspec I get an error:
PHP Warning: require(core/Common.php): failed to open stream: No such file or directory
in C:\xampp\htdocs\eljotengine\spec\ci_bootstrap.php on line 37
Warning: require(core/Common.php): failed to open stream: No such file or directory in C:\xampp\htdocs\eljotengine\spec\ci_bootstrap.php on line 37
and so on. My file structure looks like this:
eljotengine
|-application
|-sytem
|- ... other CI
|-spec
| |- ci_bootstrap.php
I am using xampp on Windows 7. My ci_bootstrap.php file looks like the one in the above mentioned article by AniDear.
I've tried to change the paths in the ci_bootstrap.php file (it seems to be the problem) however it did not change much.
Any ideas how to make this work?
Greets :)
I am having problem with PHPSpec2 too.
Since I have only tried it with PHPSpec (not PHPSpec2), I would suggest you to install PHPSpec instead. Just change the file composer.json, on the line "phpspec/phpspec2": "*" to "phpspec/phpspec": "*" , then runs composer update again.
Run this phpspec, by using command vendor\bin\phpspec.php.bat spec on your project path, whereas "spec" is the folder containing spec files.
And since you're running phpspec from your project directory, I suggest changing content inside ci_bootstrap.php as follow
define('BASEPATH',realpath('system/').'/'); //set absolute path to CI system/
define('APPPATH', 'application/'); //set relative path to CI application
set_include_path(
get_include_path().PATH_SEPARATOR.
realpath(APPPATH).PATH_SEPARATOR.
realpath(BASEPATH).PATH_SEPARATOR.
'spec'); //adding 'spec' in path, for easily do require 'ci_bootstrap.php' from inside spec files
require BASEPATH.'core/Common.php';
require APPPATH.'config/constants.php';
require BASEPATH.'core/Controller.php';