I have an error that occurs no matter what the actual error is within Laravel 5.6 It just keeps saying Could not find resource 'views/layouts.html.php' in any resource paths.(searched: /var/www/{domain}/vendor/filp/whoops/src/Whoops/Handler/../Resources) for everything that causes an error and doesn't display the full debug page that Laravel usually displays. I'm not sure what caused this or what I could do to fix it besides reinstalling Laravel, which I'd highly prefer not to do. Does anybody have any ideas what file I might be missing or what might be causing this?
Image of full error: https://i.imgur.com/5dFhlYg.png
why you use layout.html.php. Laravel has a template engine blade. you can use layout.blade.php
You Need to use views.layout. example:
return view('views.layout');
But note there are views is a folder name. if you create a folder under views folder then you can call views folder. Laravel default views folder is views don't need to call on return path.
Related
On a fresh Laravel 8 installation I follow these steps:
php artisan storage:link
Inside /public/storage/ I create folder images/ and inside I paste an image called picture.png
In web.php I define a route like this:
Route::get('/picture', function(
return response()->file(Storage::url("images/picture.png"));
))
However, if I visit this route in browser, the picture is not shown and the following error is thrown:
Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException
The file "/storage/images/picture.png" does not exist
It works only if the url inside response()->file() is prefixed with ./ indicating the current directory like this:
return response()->file('./'.Storage::url("images/picture.png"));
I don't think it is a good idea to work with relative paths locally, the Storage and file methods should handle this. Maybe it is even an issue with the framework.
Any ideas how to go around this hack?
I think you didn't configure the local driver check the documentation https://laravel.com/docs/8.x/filesystem#the-public-disk and look for local driver.
If you configure it right it should return the "/" that you're adding manually.
I am just picking up using Laravel, but I dont like Vue and have been working with the React ecosystem and would like to use React instead of Vue. Laravel Mix doesnt give me the setup I want and so I figured I could use create-react-app.
Using Laravel Valet, I have started a project in which I have also installed create-react-app in a folder called ui, at the root of the Laravel installation.
My idea is to forego some of Laravel's functionality, namely the whole frontend.
I am attempting to require the react app build html file in resources/views/main.blade.php like so:
require_once __DIR__.'/ui/build/index.html';
This gives me the error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException
(E_UNKNOWN) Illuminate\View\Engines\PhpEngine::main(): Failed opening
required
'/Users/Username/Sites/sitename/storage/framework/views/ui/build/index.html'
(include_path='.:')
This path is not correct, but I'm not sure why it is inserting /storage/framework/ into that path.
I have also tried the following, each with a similar error of Failed opening resource:
require_once('../../ui/build/index.html');
require_once($_SERVER['DOCUMENT_ROOT'].'/ui/build/index.html');
require_once(dirname(__FILE__).'/ui/build/index.html');
Laravel does not integrate with Vue, and Laravel Mix is a simple layer on top of Webpack. The default Laravel application ships with Vue scaffolding but removing that is as simple as deleting the files in resources/assets/js and if you wish to use another Javascript library then you can add that into your app.js instead.
The error you're receiving is because Laravel caches view files, meaning that they're served from the cache directory (which lives in storage/framework) so references like __DIR__ are referencing the cache directory, not the resources directory. You can see this in the documentation:
You should avoid using the DIR and FILE constants in your Blade views, since they will refer to the location of the cached, compiled view.
The correct approach to include files into your views with Blade is using the #include directive, e.g:
#include('ui.build.index')
Also, worth noting, that any time you do need to obtain the path to a file in your Laravel application you should use the base_path and app_path helpers.
Prior to continuing with development of your application you should read through the JavaScript & CSS Scaffolding documentation and the Blade documentation, as they contain a lot of information that will be very useful to you — for example, it explains how to replace Vue with React using a single command.
I started studying CodeIgniter Web Framework and I am trying to work with PHPStorm 8.0.3 on Kubuntu 14.04. When I unzip CodeIgniter downloaded archive to root Apache folder /var/www/html and go to
localhost/index.php
then it works okay and I see "Welcome to CodeIgniter!" page. Also I
can use
localhost/index.php/welcome/index
and see the same page as it should be.
When I created a new PHP project in PHPStorm and try
localhost:63342/codeignitor/index.php/
then I see welcome page, but if I use
localhost:63342/codeignitor/index.php/welcome/index
then I get 404 page. Also all my own controllers are not available and
cause 404.
I can call my own controller only if I make it default
$route['default_controller'] = 'mycontroller';
I think that this problem occurs because the URL contains name of my project /codeignitor/, but I'm not sure about it. So I need your advice how to set CodeIgniter environment in PHPStorm correctly to solve this problem. Thank you!
Codeigniter uses the URL to determine routing, therefore /codeigniter/index.php/welcome/index and /index.php/welcome/index are not equal paths. I would recommend using one or the other, and adjusting your /index.php and /config/routes.php to accommodate for your desired path.
References:
Codeigniter Subfolder
https://www.codeigniter.com/user_guide/general/urls.html
https://www.codeigniter.com/user_guide/general/routing.html
https://www.codeigniter.com/user_guide/general/environments.html
I am using and have been using the framework CodeIgniter for a while. It works perfectly on my localhost, once I upload it to a server it gives the following error message
Unable to locate the model you have specified: auth_model
To point it out, it works on my apache perfectly, do you have any idea to what the problem can be? I am talking with customer support of the webbhotel, but they can't seem to find anything on their end.
Thanks in advance.
Edit: It manages to load many different files, the session library, my own controllers, helpers and view files. It just models that it stops at, I've named them all 'Auth_model.php", 'Login_model.php' etc. The models themselves are declared class Auth_model extends CI_Model {}
Sounds like a path issue,
I would first check where your starting at and get some data to compare with
CodeIgniter FCPATH and APPATH are both set in the main index.php file,
FCPATH = root
APPATH = application folder
Find out what your paths are set to, check your config/config.php file make sure you have correct info there.
Just a thought, are you using a common auth library? Sucb as freak/ion/bit/etc auth's
The session error, is being caused by echoing data you can google the error and get a decent understanding of the error from there.
As it turns out the webhotel (one.com) got a delay when you upload, hence it was a bit troublesome to actually troubleshoot it, but here it goes. Every file name except for the exception of MY_Controller needs to be in lower cases. So the answer was pointed out by some people.
The problem is with codeigniter because it looks for lower cases only in some cases. So yeah, models should be in lower cases from now on!
When I try to generate a CRUD test for a new project I am getting a PHP Warning and a Fatal Error.
The errors relate to files that it cannot find, however, I have checked and the files are definitely there.
The error text is 'require_once(lib/model/map/QuestionMapBuilder.php): failed to open stream: No such file or directory in c:\webroot\askeet\lib\model\om\BaseQuestionPeer.php on line 547'
What details of my project should I check?
I think it's a problem with your include path.
Check it, the require_once() call is looking for lib/model/map/QuestionMapBuilder.php
But your include_path is C:\webroot\askeet\lib
Which, when resolved together into a full path, would look like this
C:\webroot\askeet\lib\lib\model\map\QuestionMapBuilder.php
So, I think your solution is to add C:\webroot\askeet to your include path.
You are generating crud for the Question model class but it doesn't seem to exist. Documentation on using the crud generator
First you must use the schema.yml file to define your database, and run
./symfony propel:build-model
to generate your model files. (this will generate lib\model\map\QuestionMapBuilder.php)
I finally tracked down the issue. In my PHP.ini files, they were setup wit the default UNIX file path settings.
Weirdly nothing had ever been broken by this incorrect configuration. Plus, everything in Symfony had worked up until now.
I have switched to Windows style file_path and all is well again.
Thanks for all the answers!