I am trying to make API project by Laravel
I created the database and configured the .env
file and installed the api
with php:artisan
But when I tried to test the URL with Postman it showed HTML code for page that said The requested URL was not found on this server.
.env
<code>APP_NAME=SKYCENTRAL
APP_ENV=local
APP_KEY=base64:havtW5AahJjp4acK6Wg8PvRewVywLlwzjcp9xdA2NnQ=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=skycentral
DB_USERNAME=root
DB_PASSWORD=
</code>
<code>APP_NAME=SKYCENTRAL
APP_ENV=local
APP_KEY=base64:havtW5AahJjp4acK6Wg8PvRewVywLlwzjcp9xdA2NnQ=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=skycentral
DB_USERNAME=root
DB_PASSWORD=
</code>
APP_NAME=SKYCENTRAL
APP_ENV=local
APP_KEY=base64:havtW5AahJjp4acK6Wg8PvRewVywLlwzjcp9xdA2NnQ=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=skycentral
DB_USERNAME=root
DB_PASSWORD=
api.php
<code><?php
use IlluminateHttpRequest;
use IlluminateSupportFacadesRoute;
use AppHttpControllersUnitController;
Route::apiResource('units', UnitController::class);
</code>
<code><?php
use IlluminateHttpRequest;
use IlluminateSupportFacadesRoute;
use AppHttpControllersUnitController;
Route::apiResource('units', UnitController::class);
</code>
<?php
use IlluminateHttpRequest;
use IlluminateSupportFacadesRoute;
use AppHttpControllersUnitController;
Route::apiResource('units', UnitController::class);
controller
<code> public function index()
{
return Unit::all();
}
</code>
<code> public function index()
{
return Unit::all();
}
</code>
public function index()
{
return Unit::all();
}
I checked the app.php
to see if the api
is installed successfully and I found that everthing is ok
<code><?php
use IlluminateFoundationApplication;
use IlluminateFoundationConfigurationExceptions;
use IlluminateFoundationConfigurationMiddleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__ . '/../routes/web.php',
api: __DIR__ . '/../routes/api.php',
commands: __DIR__ . '/../routes/console.php',
health: '/up'
)->withMiddleware(function (Middleware $middleware) {
})->withExceptions(function (Exceptions $exceptions) {
})->create();
</code>
<code><?php
use IlluminateFoundationApplication;
use IlluminateFoundationConfigurationExceptions;
use IlluminateFoundationConfigurationMiddleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__ . '/../routes/web.php',
api: __DIR__ . '/../routes/api.php',
commands: __DIR__ . '/../routes/console.php',
health: '/up'
)->withMiddleware(function (Middleware $middleware) {
})->withExceptions(function (Exceptions $exceptions) {
})->create();
</code>
<?php
use IlluminateFoundationApplication;
use IlluminateFoundationConfigurationExceptions;
use IlluminateFoundationConfigurationMiddleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__ . '/../routes/web.php',
api: __DIR__ . '/../routes/api.php',
commands: __DIR__ . '/../routes/console.php',
health: '/up'
)->withMiddleware(function (Middleware $middleware) {
})->withExceptions(function (Exceptions $exceptions) {
})->create();