{"id":39126,"date":"2026-02-15T01:41:20","date_gmt":"2026-02-14T22:41:20","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=39126"},"modified":"2026-02-15T01:41:20","modified_gmt":"2026-02-14T22:41:20","slug":"laravel-api-olusturma-rehberi-temelden-ileri-seviyeye","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/","title":{"rendered":"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye"},"content":{"rendered":"<p><body><\/p>\n<h2>Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye<\/h2>\n<p>Laravel, modern web uygulamalar\u0131 ve API&#8217;ler geli\u015ftirmek i\u00e7in g\u00fc\u00e7l\u00fc ve zarif bir PHP framework&#8217;\u00fcd\u00fcr. RESTful API&#8217;ler olu\u015fturmak i\u00e7in sundu\u011fu ara\u00e7lar ve kolayl\u0131klar sayesinde geli\u015ftiriciler aras\u0131nda pop\u00fcler bir se\u00e7imdir. Bu rehberde, Laravel kullanarak s\u0131f\u0131rdan bir API olu\u015fturma s\u00fcrecini ad\u0131m ad\u0131m ele alacak, pratik bilgiler ve kod \u00f6rnekleri sunaca\u011f\u0131z.<\/p>\n<h3>API Nedir ve Neden Laravel?<\/h3>\n<p>API (Application Programming Interface), farkl\u0131 yaz\u0131l\u0131m sistemlerinin birbiriyle ileti\u015fim kurmas\u0131n\u0131 sa\u011flayan bir dizi kural ve protokold\u00fcr. Bir API, bir uygulaman\u0131n di\u011ferine belirli bir i\u015flevi ger\u00e7ekle\u015ftirmesi veya veri sa\u011flamas\u0131 i\u00e7in istek g\u00f6ndermesine olanak tan\u0131r. \u00d6rne\u011fin, bir mobil uygulama, arka u\u00e7 sunucusundaki bir API arac\u0131l\u0131\u011f\u0131yla \u00fcr\u00fcn bilgilerini alabilir veya sipari\u015f olu\u015fturabilir.<\/p>\n<p>Laravel&#8217;in API geli\u015ftirmede \u00f6ne \u00e7\u0131kmas\u0131n\u0131n ba\u015fl\u0131ca nedenleri \u015funlard\u0131r:<\/p>\n<ul>\n<li><strong>Kolay Kurulum ve Yap\u0131land\u0131rma:<\/strong> H\u0131zl\u0131 proje olu\u015fturma ve <code>.env<\/code> dosyas\u0131 ile kolay yap\u0131land\u0131rma.<\/li>\n<li><strong>RESTful Mimari Deste\u011fi:<\/strong> Kaynak tabanl\u0131 (resource-based) API&#8217;ler i\u00e7in g\u00fc\u00e7l\u00fc y\u00f6nlendirme ve denetleyici (controller) yap\u0131lar\u0131.<\/li>\n<li><strong>ORM (Eloquent):<\/strong> Veritaban\u0131 etkile\u015fimini basitle\u015ftiren g\u00fc\u00e7l\u00fc ve sezgisel bir Object-Relational Mapper.<\/li>\n<li><strong>Kimlik Do\u011frulama ve Yetkilendirme:<\/strong> Laravel Sanctum gibi entegre \u00e7\u00f6z\u00fcmlerle API g\u00fcvenli\u011fini kolayca sa\u011flama.<\/li>\n<li><strong>Validasyon:<\/strong> Gelen istek verilerini kolayca do\u011frulama mekanizmalar\u0131.<\/li>\n<li><strong>API Kaynaklar\u0131 (Resources):<\/strong> API yan\u0131tlar\u0131n\u0131 formatlamak ve d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in esnek bir yap\u0131.<\/li>\n<li><strong>Geni\u015f Topluluk ve Dok\u00fcmantasyon:<\/strong> Kar\u015f\u0131la\u015f\u0131lan sorunlara h\u0131zl\u0131 \u00e7\u00f6z\u00fcmler bulma imkan\u0131.<\/li>\n<\/ul>\n<h3>Laravel Projesi Kurulumu ve Temel Yap\u0131land\u0131rma<\/h3>\n<p>Yeni bir Laravel projesi olu\u015fturmak olduk\u00e7a basittir. Terminalinizi a\u00e7\u0131n ve a\u015fa\u011f\u0131daki komutu \u00e7al\u0131\u015ft\u0131r\u0131n:<\/p>\n<pre><code>\ncomposer create-project laravel\/laravel my-api-project\ncd my-api-project\n<\/code><\/pre>\n<p>Proje dizinine girdikten sonra, <code>.env<\/code> dosyas\u0131n\u0131 yap\u0131land\u0131rman\u0131z gerekecektir. Bu dosya, veritaban\u0131 ba\u011flant\u0131 bilgileri, uygulama anahtar\u0131 ve di\u011fer \u00e7evresel de\u011fi\u015fkenleri i\u00e7erir.<\/p>\n<pre><code>\nAPP_NAME=\"My Laravel API\"\nAPP_ENV=local\nAPP_KEY=base64:YOUR_APP_KEY_HERE (Bu otomatik olu\u015fturulur)\nAPP_DEBUG=true\nAPP_URL=http:\/\/localhost:8000\n\nDB_CONNECTION=mysql\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=my_api_database\nDB_USERNAME=root\nDB_PASSWORD=\n<\/code><\/pre>\n<p>Veritaban\u0131n\u0131z\u0131 (\u00f6rne\u011fin <code>my_api_database<\/code>) olu\u015fturduktan sonra, Laravel&#8217;in migration&#8217;lar\u0131n\u0131 \u00e7al\u0131\u015ft\u0131rmak i\u00e7in a\u015fa\u011f\u0131daki komutu kullan\u0131n:<\/p>\n<pre><code>\nphp artisan migrate\n<\/code><\/pre>\n<p>Bu komut, Laravel&#8217;in varsay\u0131lan <code>users<\/code> ve <code>password_reset_tokens<\/code> tablolar\u0131n\u0131 veritaban\u0131n\u0131za ekleyecektir.<\/p>\n<h3>API U\u00e7 Noktalar\u0131 ve Veritaban\u0131 Etkile\u015fimi<\/h3>\n<p>Bir API&#8217;nin temelini, veritaban\u0131ndaki kaynaklar\u0131 (resource) y\u00f6neten u\u00e7 noktalar (endpoints) olu\u015fturur. Bir &#8220;\u00dcr\u00fcnler&#8221; (Products) API&#8217;si olu\u015fturarak bu s\u00fcreci inceleyelim.<\/p>\n<h4>Model ve Migration Olu\u015fturma<\/h4>\n<p>\u0130lk olarak, <code>Product<\/code> modelimizi ve bu modele kar\u015f\u0131l\u0131k gelen veritaban\u0131 tablosunu olu\u015fturmak i\u00e7in bir migration dosyas\u0131 haz\u0131rlayal\u0131m:<\/p>\n<pre><code>\nphp artisan make:model Product -m\n<\/code><\/pre>\n<p>Bu komut, <code>app\/Models\/Product.php<\/code> dosyas\u0131n\u0131 ve <code>database\/migrations<\/code> klas\u00f6r\u00fcnde yeni bir migration dosyas\u0131n\u0131 olu\u015fturacakt\u0131r. Migration dosyas\u0131n\u0131 a\u00e7\u0131n ve <code>up<\/code> metodunu a\u015fa\u011f\u0131daki gibi d\u00fczenleyin:<\/p>\n<pre><code>\n\/\/ database\/migrations\/XXXX_XX_XX_XXXXXX_create_products_table.php\n\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nreturn new class extends Migration\n{\n    public function up(): void\n    {\n        Schema::create('products', function (Blueprint $table) {\n            $table->id();\n            $table->string('name');\n            $table->text('description')->nullable();\n            $table->decimal('price', 8, 2);\n            $table->timestamps();\n        });\n    }\n\n    public function down(): void\n    {\n        Schema::dropIfExists('products');\n    }\n};\n<\/code><\/pre>\n<p>Ard\u0131ndan, migration&#8217;\u0131 \u00e7al\u0131\u015ft\u0131rmak i\u00e7in <code>php artisan migrate<\/code> komutunu tekrar kullan\u0131n.<\/p>\n<p>\u015eimdi <code>Product<\/code> modelini d\u00fczenleyerek <code>fillable<\/code> \u00f6zelliklerini tan\u0131mlayal\u0131m. Bu, hangi alanlar\u0131n toplu atama (mass assignment) yoluyla doldurulabilece\u011fini belirtir:<\/p>\n<pre><code>\n\/\/ app\/Models\/Product.php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Product extends Model\n{\n    use HasFactory;\n\n    protected $fillable = [\n        'name',\n        'description',\n        'price',\n    ];\n}\n<\/code><\/pre>\n<h4>API Controller Olu\u015fturma<\/h4>\n<p>API isteklerini i\u015fleyecek bir controller olu\u015ftural\u0131m. <code>--api<\/code> bayra\u011f\u0131n\u0131 kullanarak RESTful API metodlar\u0131n\u0131 i\u00e7eren bir controller iskeleti olu\u015fturabiliriz:<\/p>\n<pre><code>\nphp artisan make:controller Api\/ProductController --api\n<\/code><\/pre>\n<p>Bu komut, <code>app\/Http\/Controllers\/Api\/ProductController.php<\/code> dosyas\u0131n\u0131 olu\u015fturacakt\u0131r. \u0130\u00e7eri\u011fini a\u015fa\u011f\u0131daki gibi d\u00fczenleyelim:<\/p>\n<pre><code>\n\/\/ app\/Http\/Controllers\/Api\/ProductController.php\n\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Models\\Product;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Response;\n\nclass ProductController extends Controller\n{\n    \/<em><\/em>\n     * Display a listing of the resource.\n     *\/\n    public function index()\n    {\n        return response()->json(Product::all());\n    }\n\n    \/<em><\/em>\n     * Store a newly created resource in storage.\n     *\/\n    public function store(Request $request)\n    {\n        $request->validate([\n            'name' => 'required|string|max:255',\n            'description' => 'nullable|string',\n            'price' => 'required|numeric|min:0',\n        ]);\n\n        $product = Product::create($request->all());\n        return response()->json($product, Response::HTTP_CREATED); \/\/ 201 Created\n    }\n\n    \/<em><\/em>\n     * Display the specified resource.\n     *\/\n    public function show(Product $product)\n    {\n        return response()->json($product);\n    }\n\n    \/<em><\/em>\n     * Update the specified resource in storage.\n     *\/\n    public function update(Request $request, Product $product)\n    {\n        $request->validate([\n            'name' => 'sometimes|string|max:255',\n            'description' => 'nullable|string',\n            'price' => 'sometimes|numeric|min:0',\n        ]);\n\n        $product->update($request->all());\n        return response()->json($product);\n    }\n\n    \/<em><\/em>\n     * Remove the specified resource from storage.\n     *\/\n    public function destroy(Product $product)\n    {\n        $product->delete();\n        return response()->json(null, Response::HTTP_NO_CONTENT); \/\/ 204 No Content\n    }\n}\n<\/code><\/pre>\n<h4>API Rotalar\u0131n\u0131 Tan\u0131mlama<\/h4>\n<p>API rotalar\u0131 <code>routes\/api.php<\/code> dosyas\u0131nda tan\u0131mlan\u0131r. Laravel&#8217;in <code>apiResource<\/code> metodu, CRUD (Create, Read, Update, Delete) operasyonlar\u0131 i\u00e7in tek bir sat\u0131rda t\u00fcm rotalar\u0131 olu\u015fturmam\u0131z\u0131 sa\u011flar:<\/p>\n<pre><code>\n\/\/ routes\/api.php\n\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Facades\\Route;\nuse App\\Http\\Controllers\\Api\\ProductController;\n\nRoute::get('\/user', function (Request $request) {\n    return $request->user();\n})->middleware('auth:sanctum');\n\nRoute::apiResource('products', ProductController::class);\n<\/code><\/pre>\n<p>Bu tek sat\u0131r, a\u015fa\u011f\u0131daki rotalar\u0131 otomatik olarak olu\u015fturur:<\/p>\n<ul>\n<li><code>GET \/api\/products<\/code> -> <code>ProductController@index<\/code><\/li>\n<li><code>POST \/api\/products<\/code> -> <code>ProductController@store<\/code><\/li>\n<li><code>GET \/api\/products\/{product}<\/code> -> <code>ProductController@show<\/code><\/li>\n<li><code>PUT\/PATCH \/api\/products\/{product}<\/code> -> <code>ProductController@update<\/code><\/li>\n<li><code>DELETE \/api\/products\/{product}<\/code> -> <code>ProductController@destroy<\/code><\/li>\n<\/ul>\n<p>Art\u0131k <code>php artisan serve<\/code> komutu ile sunucuyu ba\u015flat\u0131p Postman veya Insomnia gibi bir ara\u00e7la API&#8217;nizi test edebilirsiniz.<\/p>\n<h3>API Kimlik Do\u011frulama (Laravel Sanctum ile)<\/h3>\n<p>\u00c7o\u011fu API, kullan\u0131c\u0131lar\u0131n kimli\u011fini do\u011frulamay\u0131 ve yetkilendirmeyi gerektirir. Laravel Sanctum, SPA (Single Page Application), mobil uygulamalar ve basit token tabanl\u0131 API&#8217;ler i\u00e7in hafif bir kimlik do\u011frulama sistemidir.<\/p>\n<h4>Sanctum Kurulumu<\/h4>\n<p>Sanctum&#8217;u projenize eklemek i\u00e7in:<\/p>\n<pre><code>\ncomposer require laravel\/sanctum\nphp artisan vendor:publish --provider=\"Laravel\\Sanctum\\SanctumServiceProvider\"\nphp artisan migrate\n<\/code><\/pre>\n<p>Bu komutlar, Sanctum&#8217;un gerekli dosyalar\u0131n\u0131 ve <code>personal_access_tokens<\/code> tablosunu olu\u015fturacakt\u0131r.<\/p>\n<h4>Kullan\u0131c\u0131 Giri\u015fi ve Token Olu\u015fturma<\/h4>\n<p>API&#8217;nize giri\u015f yapmak ve bir kimlik do\u011frulama token&#8217;\u0131 almak i\u00e7in bir endpoint olu\u015ftural\u0131m.<\/p>\n<p>Yeni bir controller olu\u015fturun:<\/p>\n<pre><code>\nphp artisan make:controller Api\/AuthController\n<\/code><\/pre>\n<p><code>AuthController<\/code> i\u00e7eri\u011fini a\u015fa\u011f\u0131daki gibi d\u00fczenleyin:<\/p>\n<pre><code>\n\/\/ app\/Http\/Controllers\/Api\/AuthController.php\n\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Facades\\Auth;\nuse Illuminate\\Http\\Response;\n\nclass AuthController extends Controller\n{\n    public function login(Request $request)\n    {\n        $credentials = $request->validate([\n            'email' => 'required|email',\n            'password' => 'required',\n        ]);\n\n        if (!Auth::attempt($credentials)) {\n            return response()->json(['message' => 'Ge\u00e7ersiz kimlik bilgileri.'], Response::HTTP_UNAUTHORIZED); \/\/ 401 Unauthorized\n        }\n\n        $user = Auth::user();\n        $token = $user->createToken('auth_token')->plainTextToken;\n\n        return response()->json([\n            'message' => 'Giri\u015f ba\u015far\u0131l\u0131.',\n            'access_token' => $token,\n            'token_type' => 'Bearer',\n        ]);\n    }\n\n    public function logout(Request $request)\n    {\n        $request->user()->currentAccessToken()->delete();\n\n        return response()->json(['message' => '\u00c7\u0131k\u0131\u015f ba\u015far\u0131l\u0131.']);\n    }\n\n    public function user(Request $request)\n    {\n        return response()->json($request->user());\n    }\n}\n<\/code><\/pre>\n<p><code>routes\/api.php<\/code> dosyan\u0131za bu endpoint&#8217;leri ekleyin:<\/p>\n<pre><code>\n\/\/ routes\/api.php\n\nuse App\\Http\\Controllers\\Api\\AuthController;\n\n\/\/ ... di\u011fer rotalar\n\nRoute::post('\/login', [AuthController::class, 'login']);\n\nRoute::middleware('auth:sanctum')->group(function () {\n    Route::post('\/logout', [AuthController::class, 'logout']);\n    Route::get('\/user', [AuthController::class, 'user']); \/\/ Kimli\u011fi do\u011frulanm\u0131\u015f kullan\u0131c\u0131y\u0131 d\u00f6nd\u00fcr\u00fcr\n    Route::apiResource('products', ProductController::class); \/\/ \u00dcr\u00fcn rotalar\u0131n\u0131 koruma alt\u0131na al\u0131yoruz\n});\n<\/code><\/pre>\n<p>Art\u0131k <code>products<\/code> rotalar\u0131na eri\u015fmek i\u00e7in HTTP ba\u015fl\u0131\u011f\u0131nda (Header) <code>Authorization: Bearer YOUR_ACCESS_TOKEN<\/code> \u015feklinde bir token g\u00f6ndermeniz gerekecektir.<\/p>\n<h3>Pratik \u0130pu\u00e7lar\u0131 ve Sonu\u00e7<\/h3>\n<h4>Validasyon (Validation)<\/h4>\n<p>Controller&#8217;\u0131n\u0131zda <code>Request<\/code> nesnesi \u00fczerinde <code>validate()<\/code> metodunu kullanmak yerine, daha temiz ve yeniden kullan\u0131labilir kod i\u00e7in Form Request s\u0131n\u0131flar\u0131n\u0131 tercih edebilirsiniz:<\/p>\n<pre><code>\nphp artisan make:request StoreProductRequest\n<\/code><\/pre>\n<p><code>app\/Http\/Requests\/StoreProductRequest.php<\/code> dosyas\u0131n\u0131 d\u00fczenleyin:<\/p>\n<pre><code>\n\/\/ app\/Http\/Requests\/StoreProductRequest.php\n\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass StoreProductRequest extends FormRequest\n{\n    public function authorize(): bool\n    {\n        return true; \/\/ \u0130stek yetkilendirme mant\u0131\u011f\u0131n\u0131 buraya ekleyebilirsiniz\n    }\n\n    public function rules(): array\n    {\n        return [\n            'name' => 'required|string|max:255',\n            'description' => 'nullable|string',\n            'price' => 'required|numeric|min:0',\n        ];\n    }\n}\n<\/code><\/pre>\n<p>Ve controller&#8217;\u0131n\u0131zda <code>Request<\/code> yerine <code>StoreProductRequest<\/code>&#8216;i kullan\u0131n:<\/p>\n<pre><code>\n\/\/ app\/Http\/Controllers\/Api\/ProductController.php (store metodu)\n\nuse App\\Http\\Requests\\StoreProductRequest;\n\npublic function store(StoreProductRequest $request)\n{\n    $product = Product::create($request->validated()); \/\/ validated() sadece ge\u00e7erli verileri d\u00f6nd\u00fcr\u00fcr\n    return response()->json($product, Response::HTTP_CREATED);\n}\n<\/code><\/pre>\n<h4>API Kaynaklar\u0131 (API Resources)<\/h4>\n<p>API yan\u0131tlar\u0131n\u0131z\u0131 standartla\u015ft\u0131rmak ve model verilerini d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in API Resources kullan\u0131n. Bu, \u00f6zellikle ili\u015fkisel verileri y\u00fcklerken veya belirli alanlar\u0131 gizlerken \u00e7ok faydal\u0131d\u0131r.<\/p>\n<pre><code>\nphp artisan make:resource ProductResource\n<\/code><\/pre>\n<p><code>app\/Http\/Resources\/ProductResource.php<\/code> dosyas\u0131n\u0131 d\u00fczenleyin:<\/p>\n<pre><code>\n\/\/ app\/Http\/Resources\/ProductResource.php\n\nnamespace App\\Http\\Resources;\n\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass ProductResource extends JsonResource\n{\n    public function toArray(Request $request): array\n    {\n        return [\n            'id' => $this->id,\n            'product_name' => $this->name, \/\/ Alan ad\u0131n\u0131 de\u011fi\u015ftirdik\n            'details' => $this->description,\n            'price_usd' => number_format($this->price, 2), \/\/ Fiyat\u0131 formatlad\u0131k\n            'created_at' => $this->created_at->format('Y-m-d H:i:s'),\n            'updated_at' => $this->updated_at->format('Y-m-d H:i:s'),\n        ];\n    }\n}\n<\/code><\/pre>\n<p>Controller&#8217;\u0131n\u0131zda kullan\u0131m\u0131:<\/p>\n<pre><code>\n\/\/ app\/Http\/Controllers\/Api\/ProductController.php\n\nuse App\\Http\\Resources\\ProductResource;\n\n\/\/ index metodu\npublic function index()\n{\n    return ProductResource::collection(Product::all()); \/\/ Koleksiyon i\u00e7in\n}\n\n\/\/ show metodu\npublic function show(Product $product)\n{\n    return new ProductResource($product); \/\/ Tek bir \u00f6\u011fe i\u00e7in\n}\n<\/code><\/pre>\n<h4>Hata Y\u00f6netimi (Error Handling)<\/h4>\n<p>Laravel, g\u00fc\u00e7l\u00fc bir hata y\u00f6netimi sunar. \u00d6zel durumlar\u0131 (exceptions) yakalamak ve uygun HTTP durum kodlar\u0131yla JSON yan\u0131tlar\u0131 d\u00f6nd\u00fcrmek \u00f6nemlidir. \u00d6rne\u011fin, bir kaynak bulunamad\u0131\u011f\u0131nda <code>404 Not Found<\/code> yan\u0131t\u0131 vermek i\u00e7in Laravel&#8217;in varsay\u0131lan model binding \u00f6zelli\u011fi yeterlidir.<\/p>\n<h4>Test Etme<\/h4>\n<p>API&#8217;nizi geli\u015ftirirken Postman, Insomnia veya cURL gibi ara\u00e7larla endpoint&#8217;lerinizi d\u00fczenli olarak test edin. Laravel ayr\u0131ca kapsaml\u0131 PHPUnit testleri yazma yetene\u011fi de sunar, bu da API&#8217;nizin g\u00fcvenilirli\u011fini art\u0131r\u0131r.<\/p>\n<h3>Sonu\u00e7<\/h3>\n<p>Bu rehberde, Laravel kullanarak bir RESTful API&#8217;nin temel bile\u015fenlerini nas\u0131l olu\u015fturaca\u011f\u0131n\u0131z\u0131 \u00f6\u011frendiniz. Model, migration, controller, rota tan\u0131mlama, Laravel Sanctum ile kimlik do\u011frulama ve pratik ipu\u00e7lar\u0131 gibi konular\u0131 ele ald\u0131k. Laravel&#8217;in sa\u011flad\u0131\u011f\u0131 ara\u00e7lar sayesinde, g\u00fc\u00e7l\u00fc, \u00f6l\u00e7eklenebilir ve bak\u0131m\u0131 kolay API&#8217;ler geli\u015ftirmek olduk\u00e7a basittir. Daha karma\u015f\u0131k senaryolar i\u00e7in, API kaynaklar\u0131, middleware&#8217;ler, rate limiting ve caching gibi Laravel&#8217;in di\u011fer \u00f6zelliklerini ke\u015ffetmeye devam edebilirsiniz.<\/p>\n<h3>S\u0131k\u00e7a Sorulan Sorular (SSS)<\/h3>\n<p><strong>S: RESTful API nedir?<\/strong><\/p>\n<p>C: RESTful API, web servisleri i\u00e7in bir mimari stildir. Temel prensipleri aras\u0131nda kaynak tabanl\u0131 olmas\u0131 (URI&#8217;ler kaynaklar\u0131 temsil eder), durum bilgisiz (stateless) olmas\u0131 (her istek sunucuya gerekli t\u00fcm bilgiyi ta\u015f\u0131r), istemci-sunucu ayr\u0131m\u0131 ve standart HTTP metodlar\u0131n\u0131n (GET, POST, PUT, DELETE) kullan\u0131lmas\u0131 bulunur.<\/p>\n<p><strong>S: Laravel&#8217;de middleware ne i\u015fe yarar?<\/strong><\/p>\n<p>C: Middleware&#8217;ler, HTTP istekleri uygulamaya ula\u015fmadan \u00f6nce veya yan\u0131tlar istemciye g\u00f6nderilmeden \u00f6nce \u00e7al\u0131\u015ft\u0131r\u0131lan kod katmanlar\u0131d\u0131r. \u00d6rne\u011fin, <code>auth:sanctum<\/code> middleware&#8217;i, bir iste\u011fin kimli\u011fi do\u011frulanm\u0131\u015f bir kullan\u0131c\u0131dan gelip gelmedi\u011fini kontrol eder.<\/p>\n<p><strong>S: API Resources neden kullan\u0131l\u0131r?<\/strong><\/p>\n<p>C: API Resources, model verilerini API yan\u0131t\u0131na d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in bir katman sa\u011flar. Bu sayede, veritaban\u0131 yap\u0131n\u0131zdan ba\u011f\u0131ms\u0131z olarak API yan\u0131t\u0131n\u0131z\u0131n yap\u0131s\u0131n\u0131 kontrol edebilir, belirli alanlar\u0131 gizleyebilir, formatlayabilir veya ili\u015fkili verileri kolayca dahil edebilirsiniz. Bu, API&#8217;nizin d\u0131\u015f d\u00fcnyaya sundu\u011fu veriyi standartla\u015ft\u0131rman\u0131za yard\u0131mc\u0131 olur.<\/p>\n<p><strong>S: CORS nedir ve Laravel&#8217;de nas\u0131l \u00e7\u00f6z\u00fcl\u00fcr?<\/strong><\/p>\n<p>C: CORS (Cross-Origin Resource Sharing), bir web sayfas\u0131ndaki JavaScript&#8217;in, farkl\u0131 bir kaynaktan (domain, protokol veya port) gelen kaynaklara istek g\u00f6ndermesini sa\u011flayan bir g\u00fcvenlik mekanizmas\u0131d\u0131r. Taray\u0131c\u0131lar, g\u00fcvenlik nedeniyle genellikle ayn\u0131 kaynak politikas\u0131n\u0131 uygular. Laravel, <code>fruitcake\/laravel-cors<\/code> paketi ile CORS&#8217;u kolayca y\u00f6netmenizi sa\u011flar. Bu paket, gelen isteklere uygun CORS ba\u015fl\u0131klar\u0131n\u0131 ekleyerek taray\u0131c\u0131lar\u0131n farkl\u0131 kaynaklardan API&#8217;nize eri\u015fmesine izin verir.<\/p>\n<p><strong>S: Laravel&#8217;de Rate Limiting (\u0130stek S\u0131n\u0131rland\u0131rma) nas\u0131l yap\u0131l\u0131r?<\/strong><\/p>\n<p>C: Laravel, API&#8217;nizin belirli bir zaman diliminde alabilece\u011fi istek say\u0131s\u0131n\u0131 s\u0131n\u0131rlamak i\u00e7in yerle\u015fik Rate Limiting \u00f6zelli\u011fine sahiptir. <code>routes\/api.php<\/code> dosyan\u0131zda <code>throttle:api<\/code> middleware&#8217;ini kullanarak veya kendi \u00f6zel rate limiter&#8217;lar\u0131n\u0131z\u0131 tan\u0131mlayarak bunu yapabilirsiniz. \u00d6rne\u011fin, <code>Route::middleware('throttle:60,1')->group(...)<\/code> ile dakikada 60 istekle s\u0131n\u0131rlayabilirsiniz.<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye\nLaravel, modern web uygulamalar\u0131 ve API&#8217;ler geli\u015ftirmek i\u00e7in g\u00fc\u00e7l\u00fc ve zarif bir PHP","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[133],"tags":[],"class_list":{"0":"post-39126","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-php","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye\" \/>\n<meta property=\"og:description\" content=\"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye Laravel, modern web uygulamalar\u0131 ve API&#039;ler geli\u015ftirmek i\u00e7in g\u00fc\u00e7l\u00fc ve zarif bir PHP\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-14T22:41:20+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye\",\"datePublished\":\"2026-02-14T22:41:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/\"},\"wordCount\":1353,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"PHP\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/#respond\"]}],\"copyrightYear\":\"2026\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/\",\"name\":\"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2026-02-14T22:41:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/","og_locale":"tr_TR","og_type":"article","og_title":"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye","og_description":"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye Laravel, modern web uygulamalar\u0131 ve API'ler geli\u015ftirmek i\u00e7in g\u00fc\u00e7l\u00fc ve zarif bir PHP","og_url":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2026-02-14T22:41:20+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"11 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye","datePublished":"2026-02-14T22:41:20+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/"},"wordCount":1353,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["PHP"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/#respond"]}],"copyrightYear":"2026","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/","url":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/","name":"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2026-02-14T22:41:20+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/laravel-api-olusturma-rehberi-temelden-ileri-seviyeye\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Laravel API Olu\u015fturma Rehberi: Temelden \u0130leri Seviyeye"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/39126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=39126"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/39126\/revisions"}],"predecessor-version":[{"id":39127,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/39126\/revisions\/39127"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=39126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=39126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=39126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}