<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohamed Fakhr</title>
    <description>The latest articles on DEV Community by Mohamed Fakhr (@mohamed_fakhr_eldin).</description>
    <link>https://dev.to/mohamed_fakhr_eldin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4031725%2F883b6001-be89-4ff4-bb2e-bcde82653847.jpeg</url>
      <title>DEV Community: Mohamed Fakhr</title>
      <link>https://dev.to/mohamed_fakhr_eldin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohamed_fakhr_eldin"/>
    <language>en</language>
    <item>
      <title>Stateful vs Stateless Authentication</title>
      <dc:creator>Mohamed Fakhr</dc:creator>
      <pubDate>Mon, 20 Jul 2026 12:38:38 +0000</pubDate>
      <link>https://dev.to/mohamed_fakhr_eldin/stateful-vs-stateless-authentication-bhe</link>
      <guid>https://dev.to/mohamed_fakhr_eldin/stateful-vs-stateless-authentication-bhe</guid>
      <description>&lt;p&gt;&lt;strong&gt;Stateful Authentication&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Session-based:&lt;/strong&gt; Relies on server-side sessions to maintain user state.&lt;br&gt;
&lt;strong&gt;How it works:&lt;/strong&gt; When a user logs in, a session is created on the server, and a session ID is stored in a cookie on the client. Subsequent requests include the session ID, allowing the server to identify the user.&lt;br&gt;
&lt;strong&gt;Advantages:&lt;/strong&gt; Simple to implement, good for traditional web applications.&lt;br&gt;
&lt;strong&gt;Disadvantages:&lt;/strong&gt; Scalability issues with large user bases, vulnerability to session hijacking, and state management complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stateless Authentication&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Token-based:&lt;/strong&gt; Relies on tokens (usually JWTs) instead of sessions.&lt;br&gt;
&lt;strong&gt;How it works:&lt;/strong&gt; After successful authentication, a JWT containing user information is issued. Subsequent requests include the token in the authorization header. The server validates the token without maintaining user state.&lt;br&gt;
&lt;strong&gt;Advantages:&lt;/strong&gt; Scalability, security, and flexibility.&lt;br&gt;
&lt;strong&gt;Disadvantages:&lt;/strong&gt; Increased complexity in token management and potential for larger payloads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Use Which&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Stateful Authentication:&lt;/strong&gt; Suitable for traditional web applications where user experience is prioritized and scalability is not a major concern.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stateless Authentication:&lt;/strong&gt; Ideal for APIs, mobile applications, and single-page applications (SPAs) where scalability, security, and statelessness are essential.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>security</category>
    </item>
    <item>
      <title>Laravel Request Lifecycle</title>
      <dc:creator>Mohamed Fakhr</dc:creator>
      <pubDate>Sun, 19 Jul 2026 16:59:03 +0000</pubDate>
      <link>https://dev.to/mohamed_fakhr_eldin/laravel-request-lifecycle-34cf</link>
      <guid>https://dev.to/mohamed_fakhr_eldin/laravel-request-lifecycle-34cf</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Request Entry Point&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The request begins at public/index.php. This file is the entry point for all incoming requests by your web server (Apache / Nginx) configuration.
&lt;/li&gt;
&lt;li&gt;It loads the Composer autoloader and instantiates the Laravel application from bootstrap/app.php.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Kernel Initialization&lt;/strong&gt;&lt;br&gt;
This kernel is responsible for handling HTTP requests and managing middleware. The request is sent to either the HTTP kernel or the console kernel, depending on the type of request. Kernels serve as the central location where all requests flow. Just focus on the HTTP kernel, which is located in app/Http/Kernel.php.&lt;/p&gt;

&lt;p&gt;The Illuminate\Foundation\Http\Kernel class is instantiated, which defines &lt;u&gt;"an array of bootstrappers"&lt;/u&gt;, which refers to a list of classes that will be run before the request is executed. These bootstrappers configure &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Error handling&lt;/li&gt;
&lt;li&gt;Logging&lt;/li&gt;
&lt;li&gt;Authentication &amp;amp; Authorization&lt;/li&gt;
&lt;li&gt;Detect the application environment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also defines a list of HTTP middleware that all requests must pass through before being handled by the application. This middleware handles &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading and writing the HTTP session&lt;/li&gt;
&lt;li&gt;Verifying the cross-site request forgery (CSRF) token.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Call the handle method in all middlewares, then after the response, call the terminate method, which runs after the request &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Service Providers&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One of the most important &lt;u&gt;kernel bootstrapping actions is loading&lt;/u&gt; the service providers for your application.&lt;/li&gt;
&lt;li&gt;Service providers are responsible for bootstrapping all of the framework's various components, such as &lt;u&gt;the database, queue, validation, and routing&lt;/u&gt; components.&lt;/li&gt;
&lt;li&gt;Service Providers are listed in config/app.php. This is the master list or array of all the service providers Laravel will load for your application.&lt;/li&gt;
&lt;li&gt;Laravel loops through them. When Laravel starts up (bootstraps), it goes through each provider in that list and creates (instantiates) an object of each service provider class.&lt;/li&gt;
&lt;li&gt;register() is called first on all providers. Purpose of register(): You tell Laravel’s service container how to build certain classes, bind interfaces, or configure services.&lt;/li&gt;
&lt;li&gt;After all providers are registered, Laravel then calls the boot() method on each one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-Why does Laravel call the &lt;strong&gt;boot()&lt;/strong&gt; method after &lt;strong&gt;register()&lt;/strong&gt; in a service provider?&lt;br&gt;
Because by the time boot() runs, all other service providers have been registered, you can safely use the services that those providers have registered.&lt;/p&gt;

&lt;p&gt;-Why are Service Providers so important?&lt;br&gt;
Essentially, every major feature offered by Laravel is bootstrapped and configured by a service provider. Everything in Laravel — routing, queues, events, mail, validation, etc. — is set up by these providers. When you install a package (like Cashier, Horizon, etc.), you often add its service provider to config/app.php so Laravel knows how to register and boot it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Route Matching&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One of the most important service providers in your application is the App\Providers\RouteServiceProvider. This service provider loads the route files contained within your application's routes directory.&lt;/li&gt;
&lt;li&gt;Once the application has been bootstrapped and all service providers have been registered, the Request will be handed off to the router, which will dispatch the request to a route or controller.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Controller Invocation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once a matching route is found, the associated controller method is executed. &lt;/li&gt;
&lt;li&gt;The controller handles the request logic, interacts with models, and prepares the response. &lt;/li&gt;
&lt;li&gt;The controller returns a response, which can be a view, JSON, or other formats.
&lt;/li&gt;
&lt;li&gt;Laravel converts the response into an HTTP response object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;7. Middleware Termination&lt;/strong&gt;&lt;br&gt;
The request passes through the middleware again, allowing for any final actions (e.g., logging, error handling).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Response Sending&lt;/strong&gt;&lt;br&gt;
The HTTP kernel's handle method returns the response object, and the index.php file calls the send method on the returned response. The send method sends the response content to the user's web browser.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
    </item>
    <item>
      <title>Laravel Autoloader</title>
      <dc:creator>Mohamed Fakhr</dc:creator>
      <pubDate>Sat, 18 Jul 2026 19:00:27 +0000</pubDate>
      <link>https://dev.to/mohamed_fakhr_eldin/laravel-autoloader-27fj</link>
      <guid>https://dev.to/mohamed_fakhr_eldin/laravel-autoloader-27fj</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is an Autoloader?&lt;/strong&gt;&lt;br&gt;
An autoloader is a piece of code that automatically loads classes when they are needed, without requiring explicit include or require statements. This saves developers from manually managing file inclusion and improves code organization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Composer Installation:&lt;/strong&gt; When you create a new Laravel project, Composer installs the required packages and generates the autoloader file. &lt;u&gt;Composer also is a package management system&lt;/u&gt; as npm for nodejs.&lt;br&gt;
&lt;strong&gt;Autoloader Activation:&lt;/strong&gt; Laravel's autoloader is triggered. It examines the class name and tries to locate the corresponding file. If the file is found, it's included, making the class available for use.&lt;/p&gt;

&lt;p&gt;The Concept Behind Laravel's Autoloader&lt;br&gt;
&lt;strong&gt;(PSR-4) Autoloading Standard:&lt;/strong&gt; PHP Standard Recommendation for autoloading. &lt;u&gt;This standard defines a mapping between class names and file paths.&lt;/u&gt;&lt;br&gt;
&lt;strong&gt;Namespace Mapping:&lt;/strong&gt; Laravel uses namespaces to organize classes. The autoloader maps namespaces to specific directories within your project structure.&lt;br&gt;
&lt;strong&gt;Classmap Generation:&lt;/strong&gt; Composer creates a classmap, which is a lookup table that maps class names to their file paths, optimizing performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is composer.lock?&lt;/strong&gt;&lt;br&gt;
The composer.lock file is auto-generated by Composer.&lt;br&gt;
Purpose:&lt;br&gt;
It locks exact versions of every package (and their dependencies).&lt;br&gt;
Ensures the project runs the same way for every developer or deployment.&lt;br&gt;
Keeps installs consistent across environments.&lt;/p&gt;

&lt;p&gt;That's why some developers don't commit and push composer.lock file so every package is installed with dependence on every developer environment. &lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
    </item>
  </channel>
</rss>
