<?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: Md.Shariful Islam</title>
    <description>The latest articles on DEV Community by Md.Shariful Islam (@sharifcse58).</description>
    <link>https://dev.to/sharifcse58</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F352748%2Fd099e3ae-63e2-4583-a542-7b473c408eb5.jpeg</url>
      <title>DEV Community: Md.Shariful Islam</title>
      <link>https://dev.to/sharifcse58</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sharifcse58"/>
    <language>en</language>
    <item>
      <title>DevOps With Laravel: Queues and Workers in Production</title>
      <dc:creator>Md.Shariful Islam</dc:creator>
      <pubDate>Sat, 17 May 2025 10:32:55 +0000</pubDate>
      <link>https://dev.to/sharifcse58/devops-with-laravel-queues-and-workers-in-production-20ji</link>
      <guid>https://dev.to/sharifcse58/devops-with-laravel-queues-and-workers-in-production-20ji</guid>
      <description>&lt;p&gt;This article contains some useful tips on how to run queues and workers in production.&lt;/p&gt;

&lt;p&gt;supervisor&lt;br&gt;
The most important thing is that worker processes need to run all the time even if something goes wrong. Otherwise they'd be unreliable. For this reason we cannot just run php artisan queue:work on a production server as we do on a local machine. We need a program that supervises the worker process, restarts it if it fails, and potentially scales the number of processes.&lt;/p&gt;

&lt;p&gt;The program we'll use is called supervisor. It's a process manager that runs in the background (daemon) and manages other processes such as queue:work.&lt;/p&gt;

&lt;p&gt;First, let's review the configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[program:worker]
command=php /var/www/html/posts/api/artisan queue:work --tries=3 --verbose --timeout=30 --sleep=3

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can define many "programs" such as queue:work. Each has a block in a file called supervisord.conf. Every program has a command option which defines the command that needs to be run. In this case, it's the queue:work but with the full artisan path.&lt;/p&gt;

&lt;p&gt;As I said, it can scale up processes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[program:worker]
command=php /var/www/html/posts/api/artisan queue:work --queue=default,notification --tries=3 --verbose --timeout=30 --sleep=3
numprocs=2

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, it'll start two separate worker processes. They both can pick jobs from the queue independently from each other. This is similar to when you open two terminal windows and start two queue:work processes on your local machine.&lt;/p&gt;

&lt;p&gt;Supervisor will log the status of the processes. But if we run the same program (worker) in multiple instances it's a good practice to differentiate them with "serial numbers" in their name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[program:worker]
command=php /var/www/html/posts/api/artisan queue:work --queue=default,notification --tries=3 --verbose --timeout=30 --sleep=3
numprocs=2
process_name=%(program_name)s_%(process_num)02d

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;%(program_name)s will be replaced with the name of the program (worker), and %(process_num)02d will be replaced with a two-digit number indicating the process number (e.g. 00, 01, 02). So when we run multiple processes from the same command we'll have logs like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnycyty76c8oo1pmfsjf7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnycyty76c8oo1pmfsjf7.png" alt="Image description" width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next we can configure ho supervisor supposed to start or restart the processes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[program:worker]
command=php /var/www/html/posts/api/artisan queue:work --queue=default,notification --tries=3 --verbose --timeout=30 --sleep=3
numprocs=2
process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;autostart=true tells supervisor to start the program automatically when it starts up. So when we start supervisor (for example when deploying a new version) it'll automatically start the workers.&lt;/p&gt;

&lt;p&gt;autorestart=true tells supervisor to automatically restart the program if it crashes or exits. Worker processes usually take care of long-running heavy tasks, often communicating with 3rd party services. It's not uncommon that they crash for some reason. By setting autorestart=true we can be sure that they are always running.&lt;/p&gt;

&lt;p&gt;Since we start two processes from queue:work it'd be great if we could treat them as one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[program:worker]
command=php /var/www/html/posts/api/artisan queue:work --queue=default,notification --tries=3 --verbose --timeout=30 --sleep=3
numprocs=2
process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;stopasgroup=true tells supervisor to stop all processes in the same process group as this one (queue:work) when it stops.&lt;/p&gt;

&lt;p&gt;killasgroup=true tells supervisor to send a kill signal to all processes in the same process group as this one (queue:work) when it stops.&lt;/p&gt;

&lt;p&gt;These option basically mean: stop/kill all subprocesses as well when the parent process (queue:work) stops/dies.&lt;/p&gt;

&lt;p&gt;As I said, errors happen fairly often in queue worker, so it's a good practice to think about them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[program:worker]
command=php /var/www/html/posts/api/artisan queue:work --queue=default,notification --tries=3 --verbose --timeout=30 --sleep=3
numprocs=2
process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=/var/log/supervisor/worker.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;redirect_stderr=true tells supervisor to redirect standard error output to the same place as standard output. We treat errors and info messages the same way.&lt;/p&gt;

&lt;p&gt;stdout_logfile=/var/log/supervisor/worker.log tells supervisor where to write standard output for each process. Since we redirect stderr to stdout we'll have one log file to every message:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcocuwhqsfg9sjz8z3tvl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcocuwhqsfg9sjz8z3tvl.png" alt="Image description" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That was all the worker-specific configuration we need but supervisor itself also need some config in the same supervisord.conf file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[supervisord]
logfile=/var/log/supervisor/supervisord.log
pidfile=/run/supervisord.pid

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;logfile=/var/log/supervisor/supervisord.log tells supervisor where to write its own log messages. This log tile contains information about the different programs and processes it manages. You can see the screenshot above.&lt;/p&gt;

&lt;p&gt;pidfile=/run/supervisord.pid tells supervisor where to write its own process ID (PID) file. These files are usually located in the run directory:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faqbcypgs4xcuna8jzeir.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faqbcypgs4xcuna8jzeir.png" alt="Image description" width="800" height="628"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By the way, PID files on Linux are similar to a MySQL or Redis database for us, web devs.&lt;/p&gt;

&lt;p&gt;They are files that contain the process ID (PID) of a running program. They are usually created by daemons or other long-running processes to help manage the process.&lt;/p&gt;

&lt;p&gt;When a daemon or other program starts up, it will create a PID file to store its own PID. This allows other programs (such as monitoring tools or control scripts) to easily find and manage the daemon. For example, a control script might read the PID file to determine if the daemon is running, and then send a signal to that PID to stop or restart the daemon.&lt;/p&gt;

&lt;p&gt;And finally, we have one more config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[supervisorctl]
serverurl=unix:///run/supervisor.sock

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This section sets some options for the supervisorctl command-line tool. supervisorctl is used to control Supervisor. With this tool we can list the status of processes, reload the config, or restart processes easily. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;supervisorctl status

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntmkydttntvrfnh0s1np.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntmkydttntvrfnh0s1np.png" alt="Image description" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally, the serverurl=unix:///run/supervisor.sock config tells supervisorctl to connect to supervisor using a Unix socket. We've already used a Unix socket when we connected nginx to php-fpm. This is the same here. supervisorctl is "just" a command-line tool that provides better interaction with supervisor and its processes. It needs a way to send requests to supervisor.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>5 levels of handling images in Laravel</title>
      <dc:creator>Md.Shariful Islam</dc:creator>
      <pubDate>Sat, 17 May 2025 09:45:00 +0000</pubDate>
      <link>https://dev.to/sharifcse58/5-levels-of-handling-images-in-laravel-3lj7</link>
      <guid>https://dev.to/sharifcse58/5-levels-of-handling-images-in-laravel-3lj7</guid>
      <description>&lt;p&gt;Image uploads are a common feature in most web applications. In this post, we'll walk through how to implement image uploads in Laravel, starting from the basics and gradually moving toward a full-featured solution. We'll cover resizing, image optimization, and UI enhancements and show how Spatie's packages and products can make the whole process easier, more efficient, and even a bit fun.&lt;/p&gt;

&lt;p&gt;Level 1: Plain Laravel and the basics of image uploads&lt;br&gt;
Let's start with a minimal example of how you can handle image uploads in Laravel using built-in functionality—no packages, just core features.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set up the form
First, you'll need a form in your Blade template that allows users to upload an image:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form
    action="{{ route('upload') }}"
    method="POST"
    enctype="multipart/form-data"
&amp;gt;
    @csrf
    &amp;lt;input type="file" name="image"&amp;gt;
    &amp;lt;button type="submit"&amp;gt;Upload&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Handle the upload in a controller
In your controller, you can handle the incoming file like this:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function store(Request $request)
{
    $request-&amp;gt;validate([
        'image' =&amp;gt; 'required|image|max:2048', // max 2MB
    ]);

    $path = $request-&amp;gt;file('image')-&amp;gt;store('uploads', 'public');

    return back()
        -&amp;gt;with('success', 'Image uploaded successfully!')
        -&amp;gt;with('path', $path);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;What you get&lt;br&gt;
✅ A working upload flow&lt;br&gt;
✅ Basic validation (image file, max size)&lt;br&gt;
✅ Storage in the public disk&lt;/p&gt;

&lt;p&gt;What's missing?&lt;br&gt;
❌ No resizing or manipulation&lt;br&gt;
❌ No optimization for performance&lt;br&gt;
❌ No UI enhancements or previews&lt;br&gt;
❌ No support for attaching images to models (like users or posts)&lt;/p&gt;

&lt;p&gt;Level 2: Adding spatie/image&lt;br&gt;
Now that basic uploads are working, let's say you want to resize or crop images before saving them. Laravel doesn't offer built-in tools for this, but Spatie's image package gives you an elegant and straightforward way to manipulate images.&lt;/p&gt;

&lt;p&gt;Using the image package, we can extend our controller to add some image resizing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function store(Request $request)
{
    $request-&amp;gt;validate([
        'image' =&amp;gt; 'required|image|max:2048',
    ]);

    $uploadedFile = $request-&amp;gt;file('image');

    // Store the original temporarily
    $path = $uploadedFile-&amp;gt;store('temp');

    // Define the final path
    $finalPath = 'uploads/' . $uploadedFile-&amp;gt;hashName();

    // Resize and save
    Image::load(storage_path('app/' . $path))
        -&amp;gt;width(800)
        -&amp;gt;save(storage_path('app/public/' . $finalPath));

    // Optionally remove the original
    Storage::delete($path);

    return back()
        -&amp;gt;with('success', 'Image resized and uploaded!')
        -&amp;gt;with('path', $finalPath);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other things you can do&lt;br&gt;
height(400) – constrain height&lt;br&gt;
fit(800, 600) – resize to fit into a box&lt;br&gt;
crop(width, height, x, y) – manually crop a section&lt;br&gt;
blur(15) – apply blur&lt;br&gt;
greyscale() – make the image black and white&lt;/p&gt;

&lt;p&gt;What you get&lt;br&gt;
✅ Image resizing and manipulation&lt;br&gt;
✅ Clean, chainable syntax&lt;br&gt;
✅ Works well for one-off or simple workflows&lt;/p&gt;

&lt;p&gt;What's missing?&lt;br&gt;
❌ No optimization (file size can still be large)&lt;br&gt;
❌ Still manual—no model integration&lt;br&gt;
❌ No UI integration&lt;/p&gt;

&lt;p&gt;Next, let's fix the performance part by optimizing the images before we store them.&lt;/p&gt;

&lt;p&gt;Level 3: Using spatie/image-optimizer to shrink file size&lt;br&gt;
So far, we've got image uploads and resizing working, but the file size might still be much larger than it needs to be. Especially for web apps, keeping images small is critical for performance. That’s where spatie/image-optimizer comes in.&lt;/p&gt;

&lt;p&gt;This package automatically optimizes images using well-known CLI tools under the hood (like jpegoptim, pngquant, and svgo)—without noticeably degrading quality.&lt;/p&gt;

&lt;p&gt;Lucky for us image-optimizer seemlesly integrates with the image package so we only need to add one line to our controller:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function store(Request $request)
{
    ...

    // Resize and save
    Image::load(storage_path('app/' . $path))
        -&amp;gt;width(800)
        -&amp;gt;optimize() // This will optimize the image before saving.
        -&amp;gt;save(storage_path('app/public/' . $finalPath));

    ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What you get&lt;br&gt;
✅ Automatically smaller file sizes&lt;br&gt;
✅ No visual quality loss&lt;br&gt;
✅ Works with any image manipulation flow&lt;/p&gt;

&lt;p&gt;What's missing?&lt;br&gt;
❌ Still no model integration&lt;br&gt;
❌ No UI integration&lt;/p&gt;

&lt;p&gt;Level 4: Using spatie/laravel-medialibrary&lt;br&gt;
Spatie's laravel-medialibrary is a powerful package that takes image uploads to the next level. It allows you to associate uploaded files (not just images!) with Eloquent models, generate automatic conversions, handle storage cleanly, and much more.&lt;/p&gt;

&lt;p&gt;Installation&lt;br&gt;
You can find the full installation instructions for laravel-media library.&lt;br&gt;
Usage&lt;br&gt;
Once installed, we can create a model, in this case a post, and simply attach our uploaded image to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function store(Request $request)
{
    $request-&amp;gt;validate([
        'title' =&amp;gt; 'required',
        'image' =&amp;gt; 'required|image|max:2048',
    ]);

    $post = Post::create([
        'title' =&amp;gt; $request-&amp;gt;input('title'),
    ]);

    $post-&amp;gt;addMediaFromRequest('image')
         -&amp;gt;toMediaCollection('featured');

    return redirect()-&amp;gt;back()
        -&amp;gt;with('success', 'Post created and image uploaded!');
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What you get&lt;br&gt;
✅ Images are attached to models&lt;br&gt;
✅ Automatic conversions (thumbs, responsive, etc.)&lt;br&gt;
✅ Clean file storage&lt;br&gt;
✅ Support for collections and multiple images&lt;/p&gt;

&lt;p&gt;What's missing?&lt;br&gt;
❌ No user-friendly upload UI&lt;br&gt;
❌ Upload experience is still native HTML form elements (no previews, drag &amp;amp; drop)&lt;/p&gt;

&lt;p&gt;Level 5: Using Media Library Pro for a polished UI uxperience&lt;br&gt;
Once you've got laravel-medialibrary set up, Media Library Pro takes things to a whole new level. It's a commercial add-on by Spatie that provides drop-in Vue and Livewire components for a modern, user-friendly image upload experience—with previews, drag &amp;amp; drop, progress bars, reordering, and more.&lt;/p&gt;

&lt;p&gt;💡 Media Library Pro is a paid product, but it will save you hours of frontend work and integrates tightly with Laravel.&lt;/p&gt;

&lt;p&gt;Media Library Pro is available for all types of frontend: Blade, Livewire, React and Vue. Installation instructions can be found in our extensive documentation.&lt;/p&gt;

&lt;p&gt;Once installed, you can add the component to your frontend code. Here's a Blade example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form method="post"&amp;gt;
    &amp;lt;x-media-library-attachment name= "image" rules= "mimes:png,jpeg,pdf"/&amp;gt;

    &amp;lt;button&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;/form
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in our controller you can handle the upload like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function store(Request $request)
{
    $request-&amp;gt;validate([
        'title' =&amp;gt; 'required',
        'image' =&amp;gt; 'required|image|max:2048',
    ]);

    $post = Post::create([
        'title' =&amp;gt; $request-&amp;gt;input('title'),
    ]);

    $post-&amp;gt;addFromMediaLibraryRequest('image')
         -&amp;gt;toMediaCollection('featured');

    return redirect()-&amp;gt;back()
        -&amp;gt;with('success', 'Post created and image uploaded!');
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which should result in a beautiful, functional upload component:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdfxf24yfcxasw0k2sbl5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdfxf24yfcxasw0k2sbl5.png" alt="Image description" width="800" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What you get&lt;br&gt;
✅ Modern, reactive UI components&lt;br&gt;
✅ Deep integration with your models&lt;br&gt;
✅ Preview, progress, reordering out of the box&lt;br&gt;
✅ Built and maintained by the creators of Media Library&lt;/p&gt;

&lt;p&gt;What's missing?&lt;br&gt;
🙌 Nothing!&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Whether you stick with Laravel's built-in tools or go all-in with Media Library Pro, how far you take your image upload implementation depends on your project's needs. The Spatie packages and products at every level offer well-crafted solutions to help you build a clean, efficient, and scalable solution.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>15 Laravel Security Best Practices in 2025</title>
      <dc:creator>Md.Shariful Islam</dc:creator>
      <pubDate>Sat, 17 May 2025 06:52:12 +0000</pubDate>
      <link>https://dev.to/sharifcse58/15-laravel-security-best-practices-in-2025-2lco</link>
      <guid>https://dev.to/sharifcse58/15-laravel-security-best-practices-in-2025-2lco</guid>
      <description>&lt;p&gt;Laravel is one of the most popular PHP frameworks, and for good reason—it's elegant, expressive, and comes with many built-in security features. But just because Laravel provides the tools doesn’t mean you’re automatically safe.&lt;/p&gt;

&lt;p&gt;Whether you're building an MVP or maintaining a large-scale application, security must be a priority.&lt;/p&gt;

&lt;p&gt;Here are 15 Laravel security best practices every developer should follow in 2025:&lt;/p&gt;

&lt;p&gt;🔐 1. Keep Laravel and Dependencies Updated&lt;br&gt;
Always keep Laravel, its dependencies, and PHP up to date.&lt;br&gt;
Laravel releases often include security patches and improvements.&lt;/p&gt;

&lt;p&gt;.&lt;br&gt;
🔒 2. Prevent SQL Injection&lt;br&gt;
Laravel's Eloquent ORM and query builder automatically use prepared statements.&lt;/p&gt;

&lt;p&gt;✅ Safe:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$users = DB::table('users')-&amp;gt;where('email', $email)-&amp;gt;get();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;❌ Avoid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB::select("SELECT * FROM users WHERE email = '$email'")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧼 3. Avoid Cross-Site Scripting (XSS)&lt;/p&gt;

&lt;p&gt;Escape all output using Blade syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{ $user-&amp;gt;name }}  // Escapes HTML output

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;.&lt;/p&gt;

&lt;p&gt;🛡️ 4. CSRF Protection&lt;br&gt;
Laravel includes CSRF protection middleware by default. Just don’t forget to include @csrf in your forms.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form method="POST" action="/submit"&amp;gt;
    @csrf
    &amp;lt;!-- form inputs --&amp;gt;
&amp;lt;/form&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👥 5. Use Built-In Auth &amp;amp; Authorization&lt;br&gt;
Leverage Laravel Breeze, Fortify, or Jetstream. Use Gates and Policies to control access.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$this-&amp;gt;authorize('update', $post);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🗝️ 6. Store Passwords Securely&lt;br&gt;
Never store plain text passwords. Laravel uses Bcrypt or Argon2 by default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hash::make('supersecret');

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔑 7. Secure Your .env and Configs&lt;br&gt;
Never commit .env files.&lt;br&gt;
Set APP_DEBUG=false in production.&lt;br&gt;
Use environment variables for credentials.&lt;br&gt;
🔐 8. Force HTTPS&lt;br&gt;
Force SSL in production.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// AppServiceProvider.php
use Illuminate\Support\Facades\URL;

public function boot()
{
    if (app()-&amp;gt;environment('production')) {
        URL::forceScheme('https');
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧾 9. Validate and Sanitize File Uploads&lt;br&gt;
Validate file size and type.&lt;br&gt;
Avoid storing files in /public if you don’t need public access.&lt;br&gt;
Sanitize filenames.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$request-&amp;gt;validate([
    'avatar' =&amp;gt; 'required|file|mimes:jpg,jpeg,png|max:2048',
]);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🍪 10. Secure Cookies &amp;amp; Sessions&lt;br&gt;
In config/session.php, set secure defaults:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'secure' =&amp;gt; env('SESSION_SECURE_COOKIE', true),
'http_only' =&amp;gt; true,
'same_site' =&amp;gt; 'lax',

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📈 11. Rate Limiting&lt;br&gt;
Prevent brute force attacks using Laravel's rate limiter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Route::middleware(['throttle:60,1'])-&amp;gt;group(function () {
    // Protected routes
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🚫 12. Avoid Mass Assignment Vulnerabilities&lt;br&gt;
Use $fillable or $guarded in your Eloquent models.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;protected $fillable = ['name', 'email'];

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📜 13. Monitor and Log Suspicious Activity&lt;br&gt;
Use Laravel logging + services like Sentry, Bugsnag, or LogRocket&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Log::warning('Suspicious login attempt', ['email' =&amp;gt; $request-&amp;gt;email]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📦 14. Vet Third-Party Packages&lt;br&gt;
Install only packages you trust. Check for:&lt;/p&gt;

&lt;p&gt;Active maintainers&lt;br&gt;
Regular updates&lt;br&gt;
Community adoption&lt;br&gt;
🔍 15. Run Regular Security Audits&lt;br&gt;
Use tools like&lt;/p&gt;

&lt;p&gt;🔍 Larastan&lt;br&gt;
🔐 Laravel Security Checker&lt;br&gt;
🧪 PHPStan&lt;br&gt;
✅ Conclusion&lt;br&gt;
Security isn’t a one-time task. It's a habit.&lt;/p&gt;

&lt;p&gt;With Laravel, you already have a strong foundation—just make sure you're using it right.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
    </item>
    <item>
      <title>Step by Step Guide Laravel CI/CD with GitHub Actions</title>
      <dc:creator>Md.Shariful Islam</dc:creator>
      <pubDate>Sat, 17 May 2025 06:30:00 +0000</pubDate>
      <link>https://dev.to/sharifcse58/step-by-step-guide-laravel-cicd-with-github-actions-4212</link>
      <guid>https://dev.to/sharifcse58/step-by-step-guide-laravel-cicd-with-github-actions-4212</guid>
      <description>&lt;p&gt;What is GitHub Actions?&lt;/p&gt;

&lt;p&gt;GitHub Actions is a free automation tool that is built into GitHub. It lets you run scripts and commands automatically when certain events happen in your repository, like pushing code or opening a pull request.&lt;/p&gt;

&lt;p&gt;Workflow Overview&lt;br&gt;
Our workflow will:&lt;/p&gt;

&lt;p&gt;Run on every push or pull request to the main or dev branches.&lt;br&gt;
Set up a MySQL database for testing.&lt;br&gt;
Install PHP and all required extensions.&lt;br&gt;
Cache Composer dependencies for faster builds.&lt;br&gt;
Install your Laravel app’s dependencies.&lt;br&gt;
Run static analysis and code quality checks.&lt;br&gt;
Run your automated tests.&lt;br&gt;
Let’s break down each step!&lt;/p&gt;

&lt;p&gt;Workflow Triggers&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;on:
  push:
    branches: ["main", "dev"]
  pull_request:
    branches: ["main", "dev"]
This tells GitHub to run the workflow every time you push code or open a pull request to the main or dev branches.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Define the Job and Environment&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jobs:
  tests:
    runs-on: ubuntu-latest
We define a job called tests that runs on the latest Ubuntu Linux environment provided by GitHub.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set Up MySQL Database&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;services:
  mysql:
    image: mysql:8.0
    ports:
      - 3306:3306
    env:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: test_db
    options: --health-cmd="mysqladmin ping"
We spin up a MySQL 8.0 database in Docker, set the root password, and create a database called test_db. The health check ensures MySQL is ready before tests run.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checkout Your Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- uses: actions/checkout@v4
This step pulls your repository’s code into the workflow environment so the next steps can work with it.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Setup PHP with All Laravel Extensions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Setup PHP with PECL extension
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.4'
    extensions: mbstring, bcmath, ctype, fileinfo, json, tokenizer, xml, pdo, pdo_mysql, openssl, curl, zip, imagick, swoole

We install PHP 8.4 and all the extensions Laravel and its ecosystem commonly need. This ensures your app runs just like it would in production.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cache Composer Dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Cache Composer dependencies
  uses: actions/cache@v4
  with:
    path: vendor
    key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
    restore-keys: |
      ${{ runner.os }}-composer-
This is “smart caching.” If your dependencies haven’t changed, Composer can skip downloading and installing them, making your workflow much faster.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the CI Environment File&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Copy .env file
  run: |
    cp .env.ci .env
We copy a special .env.ci file to .env. This file should contain settings for your test database and other CI-specific configs.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Composer Dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Install dependencies
  run: |
    composer install -q --no-ansi --no-interaction --no-scripts --no-progress
We install all PHP dependencies your Laravel app needs, using flags to make the process faster and quieter.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate Laravel Application Key&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Generate application key
  run: |
    php artisan key:generate
Laravel needs an application key for encryption and sessions. This command generates it.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set Directory Permissions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Directory permissions
  run: |
    sudo chown -R $USER:$USER storage bootstrap/cache
    chmod -R 775 storage bootstrap/cache
Laravel needs write access to storage and bootstrap/cache for logs and cache files. This step ensures the permissions are correct.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Static Analysis with PHPStan&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: phpstan
  run: |
    ./vendor/bin/phpstan analyse --level=5 --memory-limit=1G
PHPStan checks your code for bugs and potential issues without running it. This helps you catch problems early.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Code Quality Checks with PHP Insights&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: phpinsights
  run: |
    php artisan insights --no-interaction \
    --min-quality=90 --min-complexity=90 \
    --min-architecture=90 --min-style=90 \
    --ansi --format=github-action
PHP Insights analyzes your code for quality, complexity, architecture, and style. The workflow enforces minimum scores for each metric.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Show Database Configuration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Show DB config
  run: |
    grep DB_ .env
This step prints out the database settings being used, so you can verify your tests are running against the correct database.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Your Tests!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Run tests
  run: |
    php artisan test
Finally, we run all your Laravel tests. These tests will use the MySQL test database you set up earlier.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conclusion&lt;br&gt;
With this workflow, every push or pull request is automatically tested in a fresh environment, with a real database, and all the tools you need for code quality. This helps you catch bugs early, maintain high standards, and move faster as a team.&lt;/p&gt;

&lt;p&gt;Tip:&lt;/p&gt;

&lt;p&gt;Make sure your .env.ci file is committed and contains the correct database settings for CI!&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
    </item>
    <item>
      <title>SOLID in Laravel.</title>
      <dc:creator>Md.Shariful Islam</dc:creator>
      <pubDate>Wed, 07 May 2025 07:15:20 +0000</pubDate>
      <link>https://dev.to/sharifcse58/solid-in-laravel-c05</link>
      <guid>https://dev.to/sharifcse58/solid-in-laravel-c05</guid>
      <description>&lt;p&gt;SOLID in short&lt;/p&gt;

&lt;p&gt;1/ S &lt;/p&gt;

&lt;p&gt;(Single Responsibility Principle)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A class should have only one job.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep controllers and models thin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Move logic to services or traits.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2/ O&lt;/p&gt;

&lt;p&gt;(Open/Closed Principle)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Extend behavior without modifying existing code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use interfaces or abstract classes. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoid editing core logic for new features.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3/ L&lt;/p&gt;

&lt;p&gt;(Liskov Substitution Principle)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Subclasses must work like their parent class. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Methods should keep expected behavior. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoid overriding with incompatible logic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4/ I&lt;/p&gt;

&lt;p&gt;(Interface Segregation Principle)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Interfaces should be small and specific. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No class should depend on unused methods. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Split large interfaces into smaller ones.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5/ D&lt;/p&gt;

&lt;p&gt;(Dependency Inversion Principle)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Depend on interfaces, not concrete classes. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use Laravel’s Service Container for injection. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use Laravel’s Service Container&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Common Laravel Mistakes That Violate SOLID&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fat controllers violating SRP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Too much logic in Models&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Direct Database Queries in Controllers (Violates SRP &amp;amp; DIP)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Not using contracts/interfaces, leading to tight coupling (DIP).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Laravel Tools &amp;amp; Features That Support SOLID&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Service Providers &amp;amp; Dependency Injection (DIP).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Custom Requests&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Repositories &amp;amp; Interfaces (OCP, LSP).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Middleware for separating concerns (SRP).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Policies &amp;amp; Gates for clean authorization logic (SRP).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>ডাটাবেজে Collation কেন প্রয়োজন ?</title>
      <dc:creator>Md.Shariful Islam</dc:creator>
      <pubDate>Wed, 29 Jan 2025 07:02:47 +0000</pubDate>
      <link>https://dev.to/sharifcse58/ddaattaabeje-collation-ken-pryyojn-ebn-baanlaa-bhaassaar-jny-kontti-bybhaar-kraa-ucit-4a22</link>
      <guid>https://dev.to/sharifcse58/ddaattaabeje-collation-ken-pryyojn-ebn-baanlaa-bhaassaar-jny-kontti-bybhaar-kraa-ucit-4a22</guid>
      <description>&lt;p&gt;কোলেশন হলো MySQL-এ একটি নিয়মের সেট যা নির্ধারণ করে কিভাবে ডেটা সাজানো (sort) এবং তুলনা (compare) করা হবে। এটি মূলত ক্যারেক্টার এনকোডিং (character encoding) এবং স্ট্রিং অপারেশনের জন্য নিয়ম তৈরি করে, যেমন:&lt;/p&gt;

&lt;p&gt;কেস সেনসিটিভিটি (বড় হাতের অক্ষর vs ছোট হাতের অক্ষর, যেমন: A vs a)&lt;/p&gt;

&lt;p&gt;অ্যাকসেন্ট সেনসিটিভিটি (যেমন: é vs e)&lt;/p&gt;

&lt;p&gt;ভাষাভিত্তিক সাজানোর নিয়ম (যেমন: জার্মান ভাষায় ä কে a-এর কাছাকাছি সাজানো হয়, কিন্তু সুইডিশ ভাষায় z-এর পরে)।&lt;/p&gt;

&lt;p&gt;এটি ক্যারেক্টার সেট (character set)-এর সাথে যুক্ত, যা ডাটাবেসে স্টোর করা যায় এমন ক্যারেক্টার (অক্ষর) নির্ধারণ করে।&lt;/p&gt;

&lt;p&gt;কোলেশন কেন প্রয়োজন?&lt;br&gt;
১. ডেটা সাজানো (Sorting):&lt;/p&gt;

&lt;p&gt;কোলেশন নির্ধারণ করে ডেটা কোন অর্ডারে দেখানো হবে। যেমন: utf8mb4_general_ci কোলেশনে Apple এবং apple একই মনে করা হয় (কেস-ইনসেনসিটিভ), কিন্তু utf8mb4_bin-এ এরা ভিন্ন।&lt;/p&gt;

&lt;p&gt;২. স্ট্রিং তুলনা (Comparison):&lt;/p&gt;

&lt;p&gt;WHERE ক্লজ বা JOIN-এ স্ট্রিং তুলনার সময় কোলেশন নিয়ম প্রয়োগ হয়। যেমন: 'café' = 'cafe' সত্যি হবে কি না তা কোলেশন উপর নির্ভর করে।&lt;/p&gt;

&lt;p&gt;৩. সার্চিংয়ের সঠিকতা:&lt;/p&gt;

&lt;p&gt;কোলেশন অনুযায়ী সার্চ রেজাল্ট পরিবর্তিত হয়। যেমন: LIKE '%cat%' কুয়েরিতে Cat বা CAT পাওয়া যাবে কি না তা কোলেশন ঠিক করে।&lt;/p&gt;

&lt;p&gt;৪. ভাষা সমর্থন:&lt;/p&gt;

&lt;p&gt;বিভিন্ন ভাষার ক্যারেক্টার সঠিকভাবে সাজাতে বা তুলনায় কোলেশন ব্যবহৃত হয়। যেমন: স্প্যানিশ ñ বা জার্মান ß-এর জন্য আলাদা নিয়ম।&lt;/p&gt;

&lt;p&gt;৫. ডেটা সামঞ্জস্যতা:&lt;/p&gt;

&lt;p&gt;সব অপারেশনে (সাজানো, তুলনা, সার্চ) একই নিয়ম প্রয়োগ করে ডেটার ধারাবাহিকতা বজায় রাখে।&lt;/p&gt;

&lt;p&gt;কোলেশনের উদাহরণ&lt;br&gt;
utf8mb4_general_ci:&lt;/p&gt;

&lt;p&gt;কেস-ইনসেনসিটিভ, সাধারণ ইউনিকোড সাপোর্ট।&lt;/p&gt;

&lt;p&gt;A = a, É = E হিসেব করা হয়।&lt;/p&gt;

&lt;p&gt;utf8mb4_bin:&lt;/p&gt;

&lt;p&gt;বাইনারি তুলনা (কেস-সেনসিটিভ)।&lt;/p&gt;

&lt;p&gt;A ≠ a, É ≠ E।&lt;/p&gt;

&lt;p&gt;utf8mb4_unicode_ci:&lt;/p&gt;

&lt;p&gt;ইউনিকোডের সম্পূর্ণ সাপোর্ট, বহুভাষার জন্য উপযুক্ত।&lt;/p&gt;

&lt;p&gt;কোলেশন কিভাবে সেট করবেন?&lt;br&gt;
১. ডাটাবেস লেভেলে:&lt;/p&gt;

&lt;p&gt;sql&lt;br&gt;
Copy&lt;br&gt;
CREATE DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; &lt;br&gt;
২. টেবিল লেভেলে:&lt;/p&gt;

&lt;p&gt;sql&lt;br&gt;
Copy&lt;br&gt;
CREATE TABLE mytable (&lt;br&gt;
    id INT,&lt;br&gt;
    name VARCHAR(255)&lt;br&gt;
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; &lt;br&gt;
৩. কোলাম লেভেলে:&lt;/p&gt;

&lt;p&gt;sql&lt;br&gt;
Copy&lt;br&gt;
CREATE TABLE mytable (&lt;br&gt;
    id INT,&lt;br&gt;
    name VARCHAR(255) COLLATE utf8mb4_bin &lt;br&gt;
); &lt;br&gt;
কোন কোলেশন বেছে নেবেন?&lt;br&gt;
কেস সেনসিটিভিটি: _ci (কেস-ইনসেনসিটিভ) বা _bin (কেস-সেনসিটিভ) নির্বাচন করুন।&lt;/p&gt;

&lt;p&gt;ভাষার প্রয়োজন: বহুভাষার ডেটার জন্য utf8mb4_unicode_ci ভালো।&lt;/p&gt;

&lt;p&gt;পারফরম্যান্স: utf8mb4_general_ci দ্রুত, কিন্তু unicode_ci বেশি অ্যাকুরেট।&lt;/p&gt;

&lt;p&gt;সতর্কতা&lt;br&gt;
কোলেশন মিসম্যাচ: টেবিল জয়েন বা তুলনায় ভুল এড়াতে সব টেবিল/কোলামে একই কোলেশন ব্যবহার করুন।&lt;/p&gt;

&lt;p&gt;ইনডেক্সিং: কোলেশন পরিবর্তন করলে ইনডেক্স পুনরায় বিল্ড করতে হতে পারে।&lt;/p&gt;

&lt;p&gt;সংক্ষেপে&lt;br&gt;
কোলেশন MySQL-এ ডেটার সাজানো, তুলনা এবং সার্চিংকে প্রভাবিত করে। অ্যাপ্লিকেশনের ভাষা, কেস সেনসিটিভিটি এবং পারফরম্যান্সের ভিত্তিতে সঠিক কোলেশন বেছে নিন!&lt;/p&gt;

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