PHPUnit testing in PhpStorm token mismatch exception - laravel

I am running unit testing on a Laravel project through PhpStorm inbuilt test environment. I am getting token mismatch exception.
All the configurations are correct and it was working fine. Suddenly this error showed up. I tried with the terminal and it works fine. I am developing this projects under Vagrant.
What can I do to solve this issue?
I googled and found out that changing Laravel's VerifyCsrfToken as below will solve this issue. But I need this to be default as well.
$except = ['/*']

I was experiencing the same problem, i fixed it by setting the "Default configuration file" option in the chosen "Test Frameworks" to the phpunit.xml in my project root. It seems PHPStorm by default uses a 'local' phpunit config. I came to this idea while checking the runningUnitTests() method in Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
and seeing dat APP_ENV was "local" and not "testing" as specified in my PHPunit.xml
Hope this helps.

I used WithoutMiddleware trait in my testing class. It worked fine. And I tried #Lijubadr 's reply also. It worked too. thank you.

Related

CodeIgniter 4 - Refused to get unsafe header "Debugbar-Time"

I just installed CodeIgniter 4, configured the .env file to "development" and did also set the base url. For some strange reason, when I load a controller I get this error concernig the CI debug bar:
How can I solve this error?
Thanks!
You can try by removing 3rd party js plugins. In my case Paypals checkout.js is causing the issue when ci4 is in development environment. It will be gone when you switch to production
This Answer maybe too late. But I just want to inform to some poeple that have an issue like this. So in my trouble, I just remove some js in my apps. It's work for me.

Did I solve my "Target class [mail.manager] does not exist." issue?

Just upgraded from Laravel 6 to 7, and had the error response above when submitting a contact form. I eventually found a solution that seems to work and I am submitting here to help out the next guy.
In the terminal run:
composer require illuminate/mail
Add the following to the top of the controller file (app/Http/Controllers/Main.php in my case):
use \Illuminate\Support\Facades\Mail;
Add this to bootstrap/app.php:
$app->register(Illuminate\Mail\MailServiceProvider::class);
Save and test, and it worked localhost.
If the above does not work for you, there are some other possible issues and solutions available at this link, where I must give credit to vipindasks.
https://laracasts.com/discuss/channels/lumen/lumen-52-mail-not-working
Since I am suppose to ask a question:
Do you see any problems with this solution even though the site and mailer is working now?
You are simply missing a backslash. This tells the autoloader that the file you are looking for is not in the namespace your controller resides in :
$app->register(\Illuminate\Mail\MailServiceProvider::class);
Run composer update hope this will help you

Issue with CI Bonifre Module

Im using the latest version of bonfire. I created new module called 'contacts' which works fine on my localhost (public/index.php/admin/content/contacts).
I uploaded everything to the server and it works perfect... except my module. It gives me a 404.
Any ideas?
I had a similar issue. On my localhost the controllers of my new module created by the module builder work fine. But when I tried the same in the production environment I got the 404 error when viewing the module in the admin panel.
To fix the issue you need to capitalise all the controller file in your new module /application/modules/. Make sure that the class names in the controllers are capitalised as well. This fixed the issue for me.
Not sure why the localhost acts differently. Hope that helps.

Laravel's pretty var_dump(), dd(), not working anymore

For some reason laravel's dd() function decided to stop functioning. I have no idea how this happened. I tried composer update already but I'm not sure what else can be going on. The debug key is set to true in the config.
Where should I look to solve this problem? I'm using Laravel 4.2.16
NOTE:
dd() now simply functions as var_dump(), it doesn't prettify it anymore
Solved it. I loaded my vagrant machine with the wrong config and was running hhvm instead of regular php-fpm. Hence xdebug, which handles the pretty dd(), was not being loaded. I reloaded my box with the correct settings (without hhvm and hack) and everything started working again
Is dd the only Laravel helper function that doesn't work? If not then check the contents of vendor/composer/autoload_files.php. The laravel support helpers are loaded here. If the other helper functions are fine you can check the contents of laravel/framework/src/Illuminate/Support/helpers.php to see what's going on - this is where the function is created.

Spring security login error

I just implemented a simple login functionality using spring it how ever worked with the eclipse in built browser but gives the following error in chrome and firefox.
HTTP Status 404 - /SpringLogin/welcome.jsp;jsessionid=8332D4F3D4709DCA37C87F30F1EA03D5
The requested resource (/SpringLogin/welcome.jsp;jsessionid=BEE789093FF79CB6B67F8DA368E8B3E4) is not available.
can you please tell me why it is happening?
PS: I have two projects SpringLogin and both of them had same project names and both had similar packages. Then neither of the projects worked properly and gave the above error. How ever after I created another project with a different name and using different package names, it worked like magic. I am guessing here that it may have been the problem. But what is the logical answer that'll explain what happened there?
you don't have being calling the correct URL
it seems that the context /SpringLogin/ does not exists anymore.
Try /welcome.jsp or if you changed the name of application - try /newappname/welcome.jsp

Resources