Ad

Laravel 5 Symfony\Component\HttpKernel\Exception\NotFoundHttpException: POST Http://localhost/myproject/public/leads

- 1 answer

I use Laravel 5.8 and have test method like this this

public function test_store()
{
   $attribute= ['lead_name'=>'test_name','lead_family'=>'test_family'];
   $this->post('/leads', $attribute);
   $this->assertDatabaseHas('leads',  $attribute);
}

and controller like this:

class LeadController extends Controller
{
   public function store(Request $request)
   {
       Lead::create($request->all());
   }
}

and route :

Route::resource('/leads', 'App\Http\Controller\LeadController');

When I run phpunit show me this error:

Symfony\Component\HttpKernel\Exception\NotFoundHttpException: POST http://localhost/myproject/public/leads

C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling.php:118 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:326 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:120 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php:375 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php:197 C:\wamp64\www\myproject\tests\Feature\Customer\LeadTest.php:38 I test leads URL with Postman and it work correctly.

I see and read this post https://stackoverflow.com/questions/23593892/symfony-component-httpkernel-exception-notfoundhttpexception-laravel

Ad

Answer

I solved it. I change to config\app.php file

'url' =>'http://localhost/myscript_addres/public',

To

'url' =>'http://localhost/',
Ad
source: stackoverflow.com
Ad