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 want to create a bundle in my symfony project via
php bin/console generate:bundle
but it errors me in the terminal:
[Symfony\Component\Config\Exception\FileLoaderLoadException] The file
"../../src/AppBundle" does not exist (in:
C:\wamp64\www\exp\app/config) in
C:\wamp64\www\exp\app/config\services.yml (which is being imported
from "C:\wam p64\www\exp\app/config\config.yml").
[Symfony\Component\Config\Exception\FileLocatorFileNotFoundException]
The file "../../src/AppBundle" does not exist (in:
C:\wamp64\www\exp\app/config).
You might have deleted AppBundle from src folder (or test folder) manually which is the major reason for getting this error.
Browse app\config\config.yml , app\AppKernel.php and app\config\routing.yml and remove the referring to AppBundle.
Once done Please clear the cache and re-run the project.
We'd like to create a bundle which can deployed via composer/packagist for others to use. It'll wrap the logic created by the owners of MessageBird. Basically a kind of Service which will indeed be called with the container via ourvendor.messagebird.messaging.
Since it's a type of bundle (as per the docs of Sf3), we created a bundle while following the documentation:
http://symfony.com/doc/current/bundles/SensioGeneratorBundle/commands/generate_bundle.html
As the directory /src we used /vendor instead. That's when it all went wrong. Our namespace could not be located, loaded or even when we manually added it to the autoloading classes of Composer it failed all the same.
The question is, what is the best practice to go about this? We got it working right now and what we did was the following:
We created a bundle wit the following cmd:
bin/console generate:bundle --shared --namespace=OurVendor/MessageBird/MessageBirdBundle --bundle-name=MessageBirdBundle --format=yml
We moved the /src/OurVendor directory to /vendor/OurVendor as the only way to get a perfect generation was to use the default /src folder.
We manually updated the AppKernel.php
We did some debugging with namespaces for Composer but eventually we added "OurVendor\\":"vendor/" to the "autoload/psr-4" directive in root composer.json
We ran composer dumpautoload && bin/console cache:clear -e dev which resulted in an error.
We ran composer -o update which checked all dependencies and updated accordingly, including autogenerated autoload files
Strangely enough we had to add the Bundle to the AppKernel.php class and cleaned the cache again.
After all this it worked but the documentation said no such thing about developing a 3rd party vendor bundle.
http://symfony.com/doc/current/bundles/best_practices.html
So long story short, did we go about it the wrong way or what?
/vendor directory is managed by composer. Do not copy/move anything there. Don't even edit anything there, unless you understand all consequences.
When you create a shared bundle, you need to push it to a VCS of your choice, and add it as a dependency in composer.json of the project which uses it.
When you run composer update it will check-out your bundle into /vendor directory and generate correct autoload file.
Please read more how to use private repositories with composer.
Today I installed Symfony 2.7.9 for the first time and of course I've installed Sonata Admin (successfully). Now I'm trying to install SonataUserBundle like described here. But all the time I get the same error:
Unable to find file "#SonataUserBundle/Resources/config/routing/admin_resetting.xml" in
#SonataUserBundle/Resources/config/routing/admin_resetting.xml (which is being
imported from "/Users/alex/www/Personal/startup-1/app/config/routing.yml"). Make sure
the "SonataUserBundle" bundle is correctly registered and loaded in the application kernel
class. If the bundle is registered, make sure the bundle path
"#SonataUserBundle/Resources/config/routing/admin_resetting.xml" is not empty.
And YES, of course I checked admin_ressetting.xml and found that folder #SonataUserBundle/Resources/config/routing is empty.
Here my files:
config.yml, routing.yml, security.ylm, AppKernel.php
Also I'll note that:
My database contains 0 tables.
In folder src/Application/Sonata I have the only folder UserBundle
It seems there is a real issue with the 2.2.4 version of SonataUserBundle. Indeed admin_ressetting.xml is missing as you can see there.
FYI, I just posted an issue reporting the bug.
You can get the file from the master branch and create it under vendor/sonata-project/user-bundle/Resources/config/routing to fix it meanwhile.
Update (Apr, 28'16)
In fact, that's not an issue but a documentation misleading (the default documentation is ahead of last release). You need to refer to the v2.2 documentation if you want to use the last release, which is the 2.2.4 for now.
If you really checked #SonataUserBundle/Resources/config/routing which should be located under vendor/ and it's empty I would recommend you to delete vendor-directory, clear composer cache (compser clear-cache) and run composer install again.
As you can see at Github the directory should not be empty and contain more files than admin_resetting.xml.
Can't find a solution for this on stack.
I'm using ubuntu server,
$php app/console generate:bundle --namespace=WMDN/FirstBundle --format=yml
goes fine until :
Generating the bundle code: OK
Checking that the bundle is autoloaded: FAILED
Confirm automatic update of your Kernel [yes]? yes
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]? yes
Importing the bundle routing resource: OK
The command was not able to configure everything automatically.
You must do the following changes manually.
- Edit the composer.json file and register the bundle
namespace in the "autoload" section:
I thought it was permissions, and set the whole dir to 775 and made sure owner was good.
I thought it was outdated bug for symfony and deleted whole dir, and got 2.4.4
I'm following a tutorial and their bundle generates just fine and I'd like mine to do it as well.
Why can it not autoload? My Namespace should be good to use. I cannot figure it out.
I have composer installed.
Following this tutorial series : http://www.youtube.com/watch?v=GIcY5YYfZ14 and I'd really like to get my first bundle created so I may continue.
In conclusion, what are the reasons a bundle would fail autoload?
Per to comments, solution was to set the --src parameter correctly.