mercredi 8 mars 2023

Laravel auth::check return false but session exists

Many times a day Auth::check()return false.

The session is stored in redis and it exists and is not expired. Why Auth::check() should return false?

This happen many times a day for all users in the same time. ex: at 2PM all users has been logged out... at 4:38PM again, and so on.

We have laravel 5.8 and redis to store the sessions. Our app is running on a docker container



via Chebli Mohamed

mardi 7 mars 2023

Why is laravel serving me old versions of Model file

I have laravel 5.8 installed in DigitalOcean and I recently updated my code, I don't have cache enabled and yet each time I update the code, it doesn't use the new updates ... and in Sentry I receive bugs about the old code when it doesn't exist anymore, the line Sentry highlighted doesn't exist. I tried rebooting the server, restarting apache, deleting the file and uploading it again, changing the name of the function but nothing helped. Is there another cache I'm unaware of? knowing that it never happened to me



via Chebli Mohamed

Laravel: App::runningUnitTests() returns false while running unit tests

I am running unit tests on Laravel 5 and as the questions explains itself, App::runningUnitTests() is returning false during unit tests run. Why is that happening?

My PHP version is 7.1.



via Chebli Mohamed

dimanche 5 mars 2023

Laravel Call to a member function getFrameFilters() on null in

I was developing a funcionality on the dashboard of an app and unfortanetly the app sudently crashed. Supposetly the part I was developing isn't suppose to crash anything since it's on the frontend side of the app, it may be from the migration my collegue is doing but since i didn't did any git pull it's not suppose to crash. The app was originatly in Laravel 5 and where making the migration to Laravel 8.

This is the log:

[Sun Mar  5 12:49:53 2023] PHP Fatal error:  Uncaught Error: Call to a member function getFrameFilters() on null in /home/bernandre07/Desktop/dev/php/lanparty/website/vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php:285
Stack trace:
#0 /home/bernandre07/Desktop/dev/php/lanparty/website/vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php(189): Whoops\Handler\PlainTextHandler->getTraceOutput()
#1 /home/bernandre07/Desktop/dev/php/lanparty/website/vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php(292): Whoops\Handler\PlainTextHandler->generateResponse()
#2 /home/bernandre07/Desktop/dev/php/lanparty/website/vendor/filp/whoops/src/Whoops/Run.php(398): Whoops\Handler\PrettyPageHandler->handle()
#3 /home/bernandre07/Desktop/dev/php/lanparty/website/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(345): Whoops\Run->handleException()
#4 /home/bernandre07/Desktop/dev/php/lanparty/website/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(324): Illuminate\Foundation\Exceptions\Handler->rend in /home/bernandre07/Desktop/dev/php/lanparty/website/vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php on line 285

I tried to search on google the error but I didn't found a thing.



via Chebli Mohamed

samedi 4 mars 2023

Why I'm I getting a 405 Method Not Allowed when submitting forms - Laravel

I'm working on a countdown website where I have 2 forms in the same view, every time I submit 1 of those forms I'm getting a error that says:

"message": "The POST method is not supported for route /. Supported methods: GET, HEAD."

The method that I'm using in the view is a GET method and the method that I'm using in the action route of the forms are POST method.

Now, I'll show you the routes and the HTML:

My routes:

routes

HTML Form 1:

html form 1

HTML Form 2:

html form 2

I've tried by setting the hidden method with Laravel using @method('POST') in the form, but it doesn't even works, I've also tried setting the same route to the routes on the web.php file like this:

Route::get('/', function () {
    return view('welcome');
});


Route::post('/', [App\Http\Controllers\EmailController::class, 'sendEmail'])->name('send.email');
Route::post('/', [App\Http\Controllers\EmailController::class, 'saveEmail'])->name('save.email');

, but doesn't works too, every time I tried it, I was getting this error:

error

and other things that I have tried by watching YouTube tutorials and StackOverflow posts, but how I said before nothing works

I would be very grateful if you could help me.



via Chebli Mohamed

jeudi 2 mars 2023

Validate email containing special characters in Laravel [duplicate]

I am trying to validate email id which shouldn't contain some special characters using regex. There are other answers on stack overflow and i have taken this regex looking at those answers but it doesn't work.

I have tried different format of regex but none of them doesn't look to be a perfect fit or does not work.

For example, users must not register containing following special characters. *, !, #, $, &, \, ", '.

Following is the regex i am using but getting an error. I tries with other formats as well.

'email' => [
    'required', 
    'email',
    'unique:users',
    "regex:/^([^\"!'#\$\*\\]*)$/"
]

For this getting an error: preg_match(): Compilation failed: missing terminating ] for character class at offset 16

Not good at regex so if any one can give some inputs to resolve the issue.



via Chebli Mohamed

mercredi 1 mars 2023

could we integrate google recaptcha v3 without any form or submit button with php

My home page have many forms and i want to implement google recaptcha v3 with all form but it will be irritating to implement google recaptcha v3 with all forms in single page individually.So i want to implement recaptcha with page not to all individual forms.

I did implemented recaptcha v3 individually with all html forms in a single page.I want to implement recaptcha without html form.



via Chebli Mohamed