What I did before error:
1. I created a new controller in Controllers with name MyPlaceController
namespace AppHttpControllers;
use IlluminateHttpRequest;
class MyPlaceController extends Controller
{
public function index()
{
return 'this is my place';
}
}
2.
After step 1 i went to web.php and writed a code:
use IlluminateSupportFacadesRoute;
Route::get('/', function () {
return view('welcome');
});
Route::get('/my_page', 'MyPlaceController@index');
3. Starting website with command php artisan serve
After this step I got an error with text Target class [MyPlaceController] does not exist.
IlluminateContractsContainerBindingResolutionException
Target class [MyPlaceController] does not exist.
4. I tried to create those files by myself, but it didn’t worked (I also tried to create those files using cmd, but after creating there was no line with name protected $namespace 'App\Http\Controllers)
In the Laravel video course, the author used version 10. To solve this problem he went to the file called RouteServiceProvider.php and uncommented the line with the text: protected $namespace 'App\Http\Controllers' and after this action the site worked again, but in my 11 version these files are not present, and therefore I can not do the same as he did. I will also write that I have only a file named AppServiceProvider.php from all 5 files in Providers (but the author has 5 files like in the picture).
Author’s files:
- AppServiceProvider.php
- AuthServiceProvider.php
- BroadcastServiceProvider.php
- EventServiceProvider.php
- RouteServiceProvider.php
And also I want to show my project structure:
My project structure
(just in case, I apologize that my question may not have been posed very correctly)