I have the default config for this since I'm new to Laravel. When I type the mail in /password/reset view it keeps loading till a timeout error is thrown in /password/email view.
Related
Sorry for this long post I don't have any other way to describe it in short.
I have two Laravel application which are hosted in two subdomains of the same domain. One is
form.example.com another is dashboard.example.com.
The Dashboard app sends a http request to the Form app to get some JSON data. And the code it uses to send the request is like this:
$url = "https://form.example.com/api/v2/get/orders/" . urlencode($log->lastpull);
$client = new \GuzzleHttp\Client();
$request = $client->request('GET', $url);
$json = $request->getBody();
$objects = (json_decode($json));
Now the problem is that Dashboard app sometimes get a blank JSON or some error message in return from the Form app when this request is made.
However the same code works file in the localhost and when I look up the URL (https://form.example.com/api/v2/get/orders/) I get a valid JSON object. Which indicates that Form app is fine.
The error message I talked about I get from the Form app as a response for the HTTP request is this:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbl5qxvxfrl9tl.products' doesn't exist (SQL: select * from `products` order by `index` asc)
The problem with this error message is that the database it mentions 'dbl5qxvxfrl9tl' belongs to the Dashboard app! The app which is making the request.
I have no idea why the Form app is looking for its table on the Dashboard app's database. It only occurs when I host the Dashboard app on my shared hosting's server. In localhost it works fine.
I tried to export the stack trace from the error page but for some reason it was not letting me to export. So I have saved the html page:
drive.google.com/file/d/1elbJhv4BpDNlxC2Ji_463dDLndjzjbm6/view?usp=sharing
(I have replaced the domain name in this html file for privacy reasons)
As user #apokryfos commented on the main post, solution to this problem is this:
If these are two separate Laravel apps in different paths then you can also try running php artisan config:cache on both of them to generate a cache for the config so it doesn't read environment variables anymore (in case there's some cross-over)
I use the default Laravel Exception handler, but I have a question regarding good practices.
When I have a condition in which the controller must throw an exception, I do the following:
if($blah) {
abort(500, "The user should not be here");
}
and then on the frontend, I have a view that handles the error as this:
#section('message', __($exception->getMessage() ?: 'Whoops, something went wrong on our servers.'))
So that works great as long as I have the following on the .env file:
APP_DEBUG=true
Whenever I change this value to false, (as it should in production), all I get on the error page is: Server Error instead of my custom message.
How can I keep my custom error message, and have APP_DEBUG=false in production?
If you want to customize you HTTP errors for specific views or conditions, then you will have to look into Rendering exceptions section that will show you how to show a custom view for a specific exception. With this you can throw an exception like
throw new UserNotFoundException();
and listen to that exception and render a specific view as required.
I am successfully loading a page in a new window using target="_blank",but the problem is the new window is loading with an error NotFoundException, when i try to pass id from the current window to new window
{{$stud->name}}
Route::get('search/display/{$id}','studcontroller#searchstud');
.....
NotFoundException is occurred for the routes not declared.
Check if you have created a route in routes.php.
Also verify the method to be GET.
If you have cached your routes earlier, try refreshing the route cache by using the command php artisan route:cache.
NOTE: This route cache command will work only if you are not using any
closure route.
One more thing you can do to get proper link is, use Url::to() method supported by Laravel Illuminate.
You're not closing the href attribute value. So, add ":
{{$stud->name}}
Like #Alexey mentioned you where missing quotes, but you will also have to send the id parameter
{{$stud->name}}
In Laravel 5.2 docs about Implicit route model binding, there is written:
If a matching model instance is not found in the database, a 404 HTTP
response will be automatically generated.
Route:
Route::get('/product/{product}',function(Product $product){
dd($product);
});
When I enter into URL parameter existent ID, everything works as expected. But when I enter into URL nonexistent product ID, I got No query results for model [App\Product]. instead of response 404. Any ideas why?
After searching i found out solution. If you have no specified error template files in resources/views/errors default Laravel message will be shown. Just create 404.blade.php file in resources/views/errors.
I implemented the HttpUserAgent and RemoteAddr validators in Zend Framework 2 to help prevent session hijacking.
use Zend\Session\Validator\HttpUserAgent;
use Zend\Session\SessionManager;
$manager = new SessionManager();
$manager->getValidatorChain()->attach('session.validate', array(new HttpUserAgent(), 'isValid'));
It does seem to stop hijacked sessions however, it doesn't let me display a nice error message or reroute the user to the login page, Instead I get this PHP Error message:
Fatal error: Uncaught exception 'Zend\Session\Exception\RuntimeException'
with message 'Session validation failed' in \zendframework\library\Zend\Session\SessionManager.php on line 111.
Is there a callback or something else that I'm not doing to prevent the code from just dying?
This is php we don't use callbacks, but throw exceptions. You need to catch the exception and handle it from there on out.
I would recommend using the event manager and listening on the dispatch event to validate the user.