<?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: RANA SAHA</title>
    <description>The latest articles on DEV Community by RANA SAHA (@rana_saha_c704959d8988cf0).</description>
    <link>https://dev.to/rana_saha_c704959d8988cf0</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%2F2690959%2F805a86d5-9a8e-4a91-91ed-f72d5be2f2e6.png</url>
      <title>DEV Community: RANA SAHA</title>
      <link>https://dev.to/rana_saha_c704959d8988cf0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rana_saha_c704959d8988cf0"/>
    <language>en</language>
    <item>
      <title>How to Setup MongoDB with Laravel (Quick Guide)</title>
      <dc:creator>RANA SAHA</dc:creator>
      <pubDate>Sat, 01 Nov 2025 11:06:31 +0000</pubDate>
      <link>https://dev.to/rana_saha_c704959d8988cf0/how-to-setup-mongodb-with-laravel-quick-guide-115e</link>
      <guid>https://dev.to/rana_saha_c704959d8988cf0/how-to-setup-mongodb-with-laravel-quick-guide-115e</guid>
      <description>&lt;p&gt;Modern web applications often need &lt;strong&gt;scalable&lt;/strong&gt; and &lt;strong&gt;flexible&lt;/strong&gt; data storage — and that’s where &lt;strong&gt;MongoDB&lt;/strong&gt; fits perfectly.&lt;br&gt;&lt;br&gt;
It’s a NoSQL database that stores data in JSON-like documents, making it ideal for dynamic or unstructured data.&lt;/p&gt;

&lt;p&gt;By integrating &lt;strong&gt;MongoDB&lt;/strong&gt; with &lt;strong&gt;Laravel&lt;/strong&gt;, you can enjoy both:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Laravel’s expressive Eloquent-like syntax, and
&lt;/li&gt;
&lt;li&gt;MongoDB’s flexible schema and high scalability.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This step-by-step guide explains how to connect a &lt;strong&gt;Laravel&lt;/strong&gt; application with &lt;strong&gt;MongoDB&lt;/strong&gt; using the official &lt;code&gt;mongodb/laravel-mongodb&lt;/code&gt; package.&lt;br&gt;&lt;br&gt;
You’ll learn how to install dependencies, configure your environment, and test basic CRUD operations seamlessly.&lt;/p&gt;


&lt;h2&gt;
  
  
  ⚙️ What You'll Learn
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install the MongoDB driver for Laravel
&lt;/li&gt;
&lt;li&gt;Configure your &lt;code&gt;.env&lt;/code&gt; and database settings
&lt;/li&gt;
&lt;li&gt;Create models and run CRUD operations
&lt;/li&gt;
&lt;li&gt;Test your setup with Tinker
&lt;/li&gt;
&lt;li&gt;Troubleshoot connection issues
&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🧩 Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;PHP (compatible version for your Laravel installation)
&lt;/li&gt;
&lt;li&gt;Composer
&lt;/li&gt;
&lt;li&gt;A MongoDB instance (local or MongoDB Atlas)
&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  1️⃣ Install the MongoDB Laravel Package
&lt;/h2&gt;

&lt;p&gt;Run the following command in your Laravel project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require mongodb/laravel-mongodb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you need to bypass the PHP extension check (not recommended for production):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require mongodb/laravel-mongodb --ignore-platform-req=ext-mongodb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2️⃣ Configure Your .env&lt;/p&gt;

&lt;p&gt;Update your database configuration in .env:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB_CONNECTION=mongodb
MONGODB_URI="mongodb+srv://&amp;lt;username&amp;gt;:&amp;lt;password&amp;gt;@cluster0.mongodb.net"
MONGODB_DATABASE=laravel_mongo_demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace , , and the database name with your details.&lt;/p&gt;

&lt;p&gt;3️⃣ Update config/database.php&lt;/p&gt;

&lt;p&gt;Add or modify your MongoDB connection configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'mongodb' =&amp;gt; [
    'driver'   =&amp;gt; 'mongodb',
    'dsn'      =&amp;gt; env('MONGODB_URI'),
    'database' =&amp;gt; env('MONGODB_DATABASE'),
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4️⃣ Create a Model and Use It&lt;/p&gt;

&lt;p&gt;Create a model called Post:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:model Post
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create a new post
App\Models\Post::create([
    'title'  =&amp;gt; 'First Post',
    'body'   =&amp;gt; 'Testing MongoDB with Laravel.',
    'author' =&amp;gt; 'Admin',
    'status' =&amp;gt; 'published',
]);

// Fetch all posts
App\Models\Post::all();

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

&lt;/div&gt;



&lt;p&gt;5️⃣ Quick Test with Tinker&lt;/p&gt;

&lt;p&gt;Run Tinker to test the setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan tinker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then try the example create/fetch commands above.&lt;/p&gt;




&lt;p&gt;⚡ Optional — Install PHP MongoDB Extension&lt;/p&gt;

&lt;p&gt;For better performance and full driver support, install the MongoDB PHP extension.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install via PECL or your package manager.&lt;/li&gt;
&lt;li&gt;On Windows (WAMP/XAMPP):&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Download from PECL&lt;/li&gt;
&lt;li&gt;Place the .dll file in your PHP ext folder (e.g. C:\wamp64\bin\php&amp;lt;php-version&amp;gt;\ext)&lt;/li&gt;
&lt;li&gt;Add extension=mongodb to your php.ini&lt;/li&gt;
&lt;li&gt;Restart your server and verify:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -m | find "mongodb"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;🐞 Troubleshooting&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If php artisan tinker errors occur, ensure the MongoDB extension is enabled.&lt;/li&gt;
&lt;li&gt;Check your .env credentials and MongoDB Atlas IP whitelist.&lt;/li&gt;
&lt;li&gt;Review logs at storage/logs/laravel.log for driver or connection issues.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;✅ Conclusion&lt;/p&gt;

&lt;p&gt;Integrating MongoDB with Laravel is simple and powerful using the mongodb/laravel-mongodb package.&lt;br&gt;
With this setup, you can perform CRUD operations effortlessly while enjoying MongoDB’s flexibility and scalability.&lt;/p&gt;




&lt;p&gt;🔗 Resources&lt;/p&gt;

&lt;p&gt;📘 Full Blog Post:&lt;br&gt;
👉 &lt;a href="https://thelearnwithrana.blogspot.com/2025/11/how-to-setup-mongodb-with-laravel.html" rel="noopener noreferrer"&gt;How to Setup MongoDB with Laravel (on Blogger)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💻 Source Code on GitHub:&lt;br&gt;
👉 &lt;a href="https://github.com/RanaGithub30/Setup-MongoDB-with-Laravel/tree/main" rel="noopener noreferrer"&gt;RanaGithub30/Setup-MongoDB-with-Laravel&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>mongodb</category>
      <category>backend</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Set Up &amp; Use Laravel Telescope for Debugging and Monitoring</title>
      <dc:creator>RANA SAHA</dc:creator>
      <pubDate>Sun, 19 Oct 2025 14:28:19 +0000</pubDate>
      <link>https://dev.to/rana_saha_c704959d8988cf0/how-to-set-up-use-laravel-telescope-for-debugging-and-monitoring-b07</link>
      <guid>https://dev.to/rana_saha_c704959d8988cf0/how-to-set-up-use-laravel-telescope-for-debugging-and-monitoring-b07</guid>
      <description>&lt;p&gt;Ever wondered what’s happening behind the scenes in your Laravel app? Laravel Telescope gives you full visibility into requests, database queries, exceptions, jobs, mail, notifications, and more—all in one elegant dashboard. Whether you’re debugging or optimizing performance, Telescope is a must-have tool for Laravel developers.&lt;/p&gt;




&lt;p&gt;Step 1: Install Telescope&lt;br&gt;
Run this Composer command in your Laravel project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require laravel/telescope --dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The --dev flag ensures Telescope is installed only in your local environment.&lt;/p&gt;




&lt;p&gt;Step 2: Publish Telescope Assets&lt;br&gt;
After installation, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan telescope:install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then migrate the database to create the required tables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Step 3: Secure Telescope in Production&lt;br&gt;
Telescope should not be publicly accessible in production. Laravel allows you to define a gate to limit access:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;protected function gate()
{
    Gate::define('viewTelescope', function ($user) {
        return in_array($user-&amp;gt;email, [
            'admin@example.com',
        ]);
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only authorized users will be able to view Telescope if enabled in production.&lt;/p&gt;




&lt;p&gt;Step 4: Access the Telescope Dashboard&lt;br&gt;
Start your local server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open Telescope in your browser:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8000/telescope
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see tabs like Requests, Queries, Exceptions, Logs, Mail, and more.&lt;/p&gt;




&lt;p&gt;Step 5: Explore Telescope Features&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Requests: Monitor incoming HTTP requests and responses&lt;/li&gt;
&lt;li&gt;Exceptions: Track errors with full stack traces&lt;/li&gt;
&lt;li&gt;Queries: View SQL queries and execution times&lt;/li&gt;
&lt;li&gt;Jobs &amp;amp; Queues: Debug queued jobs and failures&lt;/li&gt;
&lt;li&gt;Cache: Inspect cache hits and misses&lt;/li&gt;
&lt;li&gt;Mail &amp;amp; Notifications: See emails and notifications sent by your app&lt;/li&gt;
&lt;li&gt;Logs: Centralized log entries for easier debugging&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Step 6: Manage Telescope Data&lt;br&gt;
Telescope stores data in your database. To avoid it growing too large, prune old entries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan telescope:prune --hours=48

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

&lt;/div&gt;



&lt;p&gt;You can also schedule pruning automatically in app/Console/Kernel.php:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;protected function schedule(Schedule $schedule)
{
    $schedule-&amp;gt;command('telescope:prune --hours=48')-&amp;gt;daily();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;Laravel Telescope is an essential tool for Laravel developers. It helps you debug queries, track exceptions, monitor jobs, and optimize application performance. Start using it today and see exactly what’s happening inside your application.&lt;/p&gt;

&lt;p&gt;You can also read this tutorial on my &lt;a href="https://thelearnwithrana.blogspot.com/2025/10/how-to-set-up-use-laravel-telescope.html" rel="noopener noreferrer"&gt;blogger website&lt;/a&gt;&lt;br&gt;
 for more Laravel guides and updates.&lt;/p&gt;

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