I am struggeling to get user authentication correct in a laravel 5.3 project.
To be sure of the configuration, I just started from a brand new project, but still no progress.
So these are my actions so far using https://laravel.com/docs/5.3
first downloading the latest laravel project
composer global require "laravel/installer"
then installed using
laravel new website
opening this, shows me the laravel standard template, so I consider this as a successfull installation
now, I try to use the Auth module as described in https://laravel.com/docs/5.3/authentication#retrieving-the-authenticated-user
showing:
I updated this in Controller.app, but "Auth::user()" is not possible as seen in this screenshot
This raises questions for me:
what do I do wrong to get Auth::user() working as described in the manual?
in laravel 5.2 I could write "use Auth;" in the controller using the alias as described in app.php, now the alias is found while tiping "use Auth", but still the "use ...." is written full after I type the alias and press enter. If I type "use Auth;" without pressing enter, the Auth throws an "undefined class" error. Is this an optional setting to use the alias names? or error in laravel?
Thank you
Read the Authentication Guide.
You probably forgot to run php artisan make:auth.
Related
I'm trying to open tinker in a Laravel project, but when I run php artisan tinker I get this error:
ErrorException
file_exists(): Unable to find the wrapper "hoa" - did you forget to enable it when you configured PHP?
I can't find everything similar error online, I found only similar errors but with 'wrapper http' .
Does anyone have any suggestions? Thanks
Could this be due to custom code or a library you've imported?
I often find that if I add things to the ServiceProvider or Kernel, they run before many of the artisan commands, and if I've failed to perform the proper "if" checks first, it fails.
I suppose the question I would have in return would be; Is this a fresh Laravel install or have you got custom code and libraries running? I would check there, try removing libraries you've added, HOA from my searching doesn't appear to default to Laravel.
— Happy to revise my answer should more detail be provided
Solved with this command founded on github:
composer require psy/psysh:0.11.2 --dev
I am creating my first package with Laravel 7.
Idea is make login and register process inside it.
Login and Register forms are working,
and process logic work aswell.
When I am calling them from route-file directly Blade form.
But
I have added login and register controller.
After login form send request to logged in,
comes issues:
Issue 1) Trait Illuminate\Foundation\Auth\AuthenticatesUsers
not found.
Tried so far:
added "laravel/ui" to Composer.json inside my package.
---- Edit ---
I found "illuminate/auth" from Github/Laravel/framework/blob/7.x/src/illuminate/Auth/composer.json
namespace is same as error.
installed but still same error.
Q) Do I miss some other package which calls User trait ?
Thanks Mika.
--- EDIT ----
I have been searcing few days to way to do it.
Found https://laracasts.com/discuss/channels/laravel/create-laravel-route-inside-another-composer-packages
But it is for Larave 5.X, is it still valid way to fix this problem ?
If you want to use Laravel's built in authentication, this is how you set it up:
Run
composer require laravel/ui
Then run
php artisan ui:auth
and
php artisan migrate
If you want to use Vue with the UI scaffolding you can run php artisan ui vue --auth instead of php artisan ui:auth.
So I'd recommend to undo what you did (seems like you didn't run through the install steps properly) and then follow the steps above. More info in the official documentation.
The trait you're trying to use is in fact inside laravel/ui, so you should still require this package in your composer.json: https://github.com/laravel/ui/blob/2.x/auth-backend/AuthenticatesUsers.php
I would also try running composer dump-autoload after installing the laravel/ui package (this should clear any cached autoloaders).
Also, please don't forget to properly import the AuthenticatesUsers trait in your controller:
use Illuminate\Foundation\Auth\AuthenticatesUsers;
...
class LoginController extends Controller
{
use AuthenticatesUsers;
...
}
I've added Laravel Nova to my Laravel app (v7.x). There is nothing special configured within my middlewares/service providers/etc.
Whenever I submit a form from Nova, it results in a 419 Page expired error.
The VerifyCsrfTokenMiddleware throws an error, saying there is a "CSRF token missmatch".
All views and assets are default as they came by the Laravel Nova installation script.
Any idea, what causes this problem?
I recently faced the same problem. I resolved it by adding the following line to my .env file:
SESSION_DOMAIN=.domain.tld
Where domain.tld is your domain obviously. Don't forget the initial dot.
Also, if you're using Laravel passport and your site is fresh, don't forget to execute php artisan passport:install
I have a running app written on Laravel 5.7. I tried to change the record in composer.json to match "5.8.*" and ran composer update. On my local (win10/WAMP) machine it went fine, but on the staging server (Debian 9/nginx) the update command changed the vendor contents and failed at the end.
Since then anything I do with the app on the server I get this error and I can't find any information anywhere.
Call to undefined method Illuminate\Routing\RouteFileRegistrar::get()
And this is the line that fails:
$this->get('login', 'Auth\LoginController#showLoginForm')->name('login');
Thanks in advance!
remove "$this" from your routes and use "Route::"
It is a problem with the routes. Mainly, you get this problem when you are using routes with resource or resources. Make sure you do not have any problem in routes by using the command:
#php artisan route:list
If you are getting any problem while route listing please fix it.
I solved this problem in Laravel 5.8 by fixing routes.
Hope this will help.
Since I've upgraded to Laravel version 5.6 from Laravel version 5.5 my Logger doesn't work properly anymore.
At first I got the following error stack :
laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at /home/vagrant/Code/grotesmurf/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:181)
which was solved by simply adding the new config/logging.php file that is provided by Laravel 5.6.
But now I'm getting no output from the Logger! I'm simply running \Log::info('hello!') as a tinker command, but it doesn't generate any log output anymore (same for scripts calling the \Log() method).
I've tried different LOG_CHANNEL settings (daily, single, stack), but none of these work.
Hope anyone has ran into this error already and is able to provide me with some suggestions. I have followed the upgrade guide and it doesn't help unfortunately.
Thanks in advance.
P.S. I'm running php version 7.1 & am on ubuntu.
P.P.S. I have cleared all cached config using artisan.
Well I have found the actual problem, we use an adjusted storage_path() method in our application and the new Logger is now using the storage_path() method to generate its path - this caused the log file to be created in a different directory than storage/logs.
i had the same issue, deleting the files in bootstrap/cache solved it.