APP_DEBUG=true is being ignored - php

I have APP_DEBUG=true in the .env file:
APP_ENV=local
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://test.dev
I've deliberately use incorrect incorrect url (eg: test.dev/asdsadsa) which does not in the web.php route file.
I expected to get an laravel debug error when route does not exist
Sorry, the page you are looking for could not be found.
NotFoundHttpException in RouteCollection.php line 161:
However, it keep showing 404 error page (views/errors/404.blade.php) even APP_DEBUG is set to true.
What I have tried:
1 - I even tested to make sure laravel can read .env file:
Route::get('/', function() {
dd(env('APP_DEBUG'));
});
return true
2 - php artisan config:cache did not fix it.
3 - chmod -R 777 storage did not fix it.

if you have 404 error page in views/errors it will be displayed, and if you haven't, NotFoundHttpException will be displayed.

I'm very late to the game here, but if nothing else worked try clearing all cache and then run:
php artisan optimize:clear

Just add this two lines in your error view, for example in views\errors\404.blade.php
<?php $e = new Symfony\Component\Debug\ExceptionHandler(); ?>
<?php echo getenv('APP_DEBUG') == 'true' ? $e->getContent(Symfony\Component\Debug\Exception\FlattenException::create($exception)) : ''; ?>
This will show the laravel debug error in your custom 404 error page.

Remove make sure that Your App\Exceptions\Handler does not have in $dontReport this line:
'Symfony\Component\HttpKernel\Exception\HttpException'
take a look at documentation: https://laravel.com/docs/5.3/errors#the-exception-handler
and find:
Ignoring Exceptions By Type
The $dontReport property of the exception handler contains an array of
exception types that will not be logged. For example, exceptions
resulting from 404 errors, as well as several other types of errors,
are not written to your log files. You may add other exception types
to this array as needed

Make sure you have .env file in the root folder of the laravel project. If you don't have one, please search how to create laravel .env file and create it.

Related

google recaptcha v2 in livewire component comes with issues

I'm trying to implement google recaptcha v2 with livewire but I get some issues :
The issue that I get is when I try to call RECAPTCHA_SITE_KEY from the .env file it display me this error message in Dev Console :
"Uncaught Error: Missing required parameters: sitekey"
it confusing because the site key is correct and is already exist inside .env file.
Wile I remove the {{ env('RECAPTCHA_SITE_KEY') }} from data-sitekey and add the site key it work
Not Working example :
data-sitekey="{{ env('RECAPTCHA_SITE_KEY') }}"
"Uncaught Error: Missing required parameters: sitekey"
Working example :
data-sitekey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
Where this problem coming from ?
First, double check that is is spelled exactly the same in your .env. Second, run php artisan cache:clear in case your config is cached. Third, attempt env('RECAPTCHA_SITE_KEY'); from php artisan tinker and see what results you get.

Uploaded Laravel project on 000WebHost that's not working

I recently uploaded my laravel blog project on 000WebHost, after that I redirected to URL http://laravelcreativeblog.000webhostapp.com/, but I saw this error Whoops, looks like something went wrong., this error is displayed two times one after the other. So I googled that and finally I reached to the a solution that there is an error in APP_KEY which I found here /public_html/storage/logs/laravel.log and error at last is:
[2018-10-18 15:44:47] production.ERROR: No application encryption key
has been specified. {"exception":"[object] (RuntimeException(code: 0):
No application encryption key has been specified. at
/storage/ssd1/217/7530217/public_html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:42)
[stacktrace]
So I generated Application Key from CMD by php artisan key:generate and put in the .ENV File but again getting that error.
This is all I done, so any suggestions???
I fixed the error the error was that 000WebHost does not support .ENV file variables, so we must add all .env detials into config/app.php file and database details into config/database.php. Read the last FAQ here, https://www.000webhost.com/forum/t/deploy-laravel-project-into-000webhost-site/127323 for more details(only for 000WebHost).
When you receive "No application encryption key" error:
be sure that you have .env file in root directory
run php artisan key:generate

#section('content') in Laravel 5.2 seems not to work on a creation route

I'm trying to visit the /create route, but it displays the navbar with a blank page. It should however be the content from a section.
Here's the example:
#extends('layout')
#section('content')
<p>The create form.Tl:dr.</p>
#stop
I also made an edit page, and it works fine, with the exactly same code (unless the method, it's different).
The problem began after I ran php artisan make:auth, but I don't think that is the source of this error.
The controller: https://codeshare.io/xpJm3
The routes: https://codeshare.io/QBxxw
Solved.
How to solve it:
Check your logs files on ..\storage\logs\laravel.log. Makes sure you delete all logs so you can easily find the newest log.
Reload the pages who have error.
Back to the logs files, if you see the error like:
RuntimeException in compiled.php line xxx: No supported encrypter found. The cipher and / or key length are invalid.
Check your config\app.php . Search for 'cipher' => 'somekey' , change the somekey value to 'AES-256-CBC'
Reload the page again.
If you still can't see the content like what happened to me before, run this command on your root directory:
php artisan key:generate
Now, you're done.
Added:
Also, don't forget add this:
public function __construct()
{
$this->middleware('auth');
}
To your controller.

Empty services.json file is breaking site

I'm getting the
Whoops, looks like something went wrong.
on my production server.
All the sudden, no artisan commands are working. I was getting an error on /bootstrap/compiled.php:4496.
After removing compiled.php, I'm getting the same message
"array_merge(): Argument #2 is not an array" in /vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository".php:188.
My services.json files is empty, and when I try to PHP artisan cache:clear, I receive the same error message.
Does anyone know what I can try next? Thanks in advance
It looks like we ran out of space on the server. That's why it couldn't write to the file.
When Laravel is on production without debug option this message is shown "Whoops, looks like something went wrong.", you can edit you .env line
APP_DEBUG=false
to
APP_DEBUG=true
and then you will see error(have more info about error) you will know how to fix.
Removing services.json from bootstrap/cache fixed the issue.
Source: https://laracasts.com/discuss/channels/laravel/update-to-51-and-array-merge-argument-2-is-not-an-array
have you tried to delete your vender + /bootstrap/compiled.php and your service.json and then tried to reinstall laravel again using composer install ?

Laravel 5.1 View not found

this seems to be an issue that pops up every now and then within Laravel. I was writing a CRUD controller with a view to go with it, however upon testing I got the InvalidArgumentException in FileViewFinder.php line 137: View [bookingcrud.index] not found error. Here is my code:
routes.php:
Route::resource('bookingcrud', 'BookingsCrudController');
BookingsCrudController.php
use uasc\Http\Requests;
use uasc\Http\Requests\CrudCreateRequest;
use uasc\Http\Requests\CrudUpdateRequest;
use uasc\Http\Controllers\Controller;
use Auth;
use DB;
use Illuminate\Pagination\Paginator;
use Illuminate\Http\Request;
class BookingsCrudController extends Controller {
public function index()
{
if (!Auth::check() || Auth::user()->authority < 1) {
return redirect('/login');
}
$raw = "select * from bookings";
$bookings = DB::select($raw);
$paginatedBookings = new Paginator($bookings, 1);
return view('bookingcrud.index')->with('bookings', $paginatedBookings);
}
}
And a view located in ~/laravel/resources/views/bookingcrud/index.blade.php
No matter what is in this view file whether its markup from a working view or just the word "cheese" i will always get:
InvalidArgumentException in FileViewFinder.php line 140:
View [bookingcrud.index] not found.
I tested the same view in a known working controller and got the same error however I tested a known working view on the same CRUD controller and it worked. I have also tried changing the directory of the view and renaming it but i'll get the same error with the "View [bookingcrud.index]" changing appropriately. I made sure the permissions of the file and directories were full for testing.
Since first getting the error I have upgraded to 5.1.1 from 5.0.26 (which is the version the error originated on for me) and ran composer update. Also from looking at threads with the same error I have also ran artisan config:clear
I am developing on Windows 8.1 with Homestead 2.0.17 deployed with Virtual Box.
Any help would much appriciated at this point it is doing my head in.
Please use terminal
homestead ssh > Press Enter
vagrant#homestead cd /Path_of_Your_Project/
vagrant#homestead:~/Path_of_Your_project php artisan cache:clear
vagrant#homestead:~/Path_of_Your_project php artisan config:cache
Sorry about my English
Turns out I had spelt blade incorrectly, took a second pair of eyes to notice it though.
$ ls resources/views/crud/booking/
crud.balde.php index.balde.php
Was definitely a lesson to always double check the small things when debugging.
Thanks for the help.
For someone who don't have SSH Access, There are two ways to solve this problem.
If you don't have any plugin of default Laravel package,
First, Just remove the bootstrap/cache/config.php to solved the file,
OR
If you have any plugin of default Laravel package,
Change all related path mentioned bootstrap/cache/config.php into the exact path which allocated the laravel project.
Remember that Linux is case sensitive!
I had something like this:
return view('MyView', $data);
And it was working on my environment (Mac OS), but not on the deployment server (Ubuntu)!

Categories