<?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: Snehal Rajeev Moon</title>
    <description>The latest articles on DEV Community by Snehal Rajeev Moon (@snehalkadwe).</description>
    <link>https://dev.to/snehalkadwe</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%2F672647%2Ff5b2df23-eca9-4c16-b6df-ba54004abfda.JPG</url>
      <title>DEV Community: Snehal Rajeev Moon</title>
      <link>https://dev.to/snehalkadwe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/snehalkadwe"/>
    <language>en</language>
    <item>
      <title>What is a Large Language Model (LLM)</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Fri, 10 Oct 2025 16:51:14 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/what-is-a-large-language-model-llm-2gca</link>
      <guid>https://dev.to/snehalkadwe/what-is-a-large-language-model-llm-2gca</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Large Language Models (LLMs): What They Are and Why They Matter&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’ve used ChatGPT, typed into Google Search, or even played with AI-powered image generators, you’ve already brushed shoulders with something called a Large Language Model (LLM). Sounds fancy, right? But at its core, an LLM is simply a type of artificial intelligence trained to understand and generate human-like text.&lt;/p&gt;

&lt;p&gt;Think of it like this: an LLM is a supercharged autocomplete. Just like when your phone guesses the next word in your text message, an LLM predicts what comes next in a sentence. The big difference? Instead of being trained on a few messages, it’s been trained on massive amounts of text—from books, articles, websites, and more—so it can carry on conversations, answer questions, summarize documents, or even write poems and code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How LLMs Work (Without the Tech Jargon)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you’ve read every book in your local library. Over time, you’d start noticing patterns—how stories are structured, what words often go together, how different writers explain ideas. That’s pretty much what an LLM does, but at an internet scale.&lt;/p&gt;

&lt;p&gt;Instead of memorizing every single page, the model learns the patterns of language. That’s why it can generate a Shakespeare-style sonnet or explain quantum physics in plain English, depending on what you ask.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-World Examples You’ll Recognize&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Customer support bots:&lt;/em&gt;&lt;/strong&gt; Ever chatted with a help bot that actually gave you a useful answer instead of "please hold"? That’s often an LLM at work.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Email drafting:&lt;/strong&gt;&lt;/em&gt; Tools like Gmail’s “Smart Compose” use LLM tech to guess what you’re about to type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Education:&lt;/em&gt;&lt;/strong&gt; Students use LLMs to get study help—like asking, “Explain photosynthesis to me like I’m 10.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Coding:&lt;/em&gt;&lt;/strong&gt; Developers use models like GitHub Copilot to write chunks of code faster, almost like pair-programming with a tireless teammate.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Creative writing:&lt;/strong&gt;&lt;/em&gt; Writers use LLMs as brainstorming partners, bouncing off ideas for stories, blog posts, or even song lyrics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Human Side: Why People Care&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What makes LLMs powerful isn’t just their ability to spit out words—it’s how they save time, spark creativity, and make complex things easier to grasp. Instead of spending an hour writing a report, you might draft one in ten minutes with AI help and then fine-tune it. Instead of struggling to learn a new concept, you can have it explained in simple terms, step by step.&lt;/p&gt;

&lt;p&gt;Of course, they’re not perfect. Sometimes they “hallucinate” (make up facts) or produce answers that sound confident but are flat-out wrong. That’s why they’re best used as assistants, not replacements for human judgment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where It’s All Headed&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;LLMs are still evolving fast. We’re seeing models that don’t just handle text but also images, audio, and even video. The future isn’t just about chatting with AI—it’s about AI becoming a tool you can collaborate with in almost any task.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;But here’s the key thing to remember: LLMs don’t “think” like us. They don’t have beliefs, opinions, or feelings. They’re pattern machines—powerful ones—that work best when guided by human goals and values.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Large Language Models aren’t science fiction anymore—they’re everyday tools. Whether you’re asking Siri to set a timer, having ChatGPT explain a tricky subject, or using AI to boost productivity at work, you’re seeing them in action.&lt;br&gt;
The real trick isn’t just knowing that LLMs exist. It’s learning how to use them well: asking the right questions, checking their answers, and treating them like the powerful assistants they are.&lt;/p&gt;

&lt;p&gt;Happy Reading!! ❤️ 🦄&lt;/p&gt;

</description>
      <category>ai</category>
      <category>wecoded</category>
      <category>programming</category>
    </item>
    <item>
      <title>MCP Servers Made Simple: Why Model Context Protocol Matters for AI</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Sat, 13 Sep 2025 17:58:30 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/mcp-servers-made-simple-why-model-context-protocol-matters-for-ai-1ppf</link>
      <guid>https://dev.to/snehalkadwe/mcp-servers-made-simple-why-model-context-protocol-matters-for-ai-1ppf</guid>
      <description>&lt;p&gt;&lt;strong&gt;What Is an MCP Server and Why Should You Care?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’ve been around development or systems engineering circles, you may have heard the term MCP server pop up. But what exactly is it, and why is it important? Let’s break it down without jargon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Is an MCP Server?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;MCP stands for Model Context Protocol. An MCP server is essentially a backend service that exposes resources, data, or tools in a standardized way so that AI models (like ChatGPT) and client applications can use them consistently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Think of it as a translator:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On one side, you have tools, APIs, and data sources.&lt;/p&gt;

&lt;p&gt;On the other hand, you have AI models or client apps that need structured, safe access to those resources. The MCP server sits in the middle and makes sure the connection works smoothly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Does MCP Matter?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AI systems are powerful, but they don’t natively know how to interact with every API, database, or tool you use. Without a common standard, each integration would be a one-off hack. That’s messy and not scalable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;MCP fixes this problem by providing:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consistency&lt;/strong&gt; – Clients and models know what to expect, no matter the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt; – Access to tools and data can be sandboxed and controlled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extensibility&lt;/strong&gt; – You can add new servers for new tools without breaking old ones.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Future-proofing&lt;/strong&gt; – As AI evolves, the protocol ensures integrations don’t constantly need rework.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How MCP Servers Work&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;At a high level, here’s the flow:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The MCP server registers its capabilities: what tools, data, or endpoints it provides.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A client (like a model-aware application) connects to it using the MCP standard.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The AI model requests operations—querying data, running a tool, retrieving results—through the MCP server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Responses flow back in a predictable format.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This setup means developers can plug in different MCP servers—say one for a database, one for a file system, and one for a third-party API—and the client can use them all without special casing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Cases for MCP Servers&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enterprise apps&lt;/strong&gt; – Securely connect AI to internal databases or document stores.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DevOps&lt;/strong&gt; – Give AI structured access to logs, configs, or cloud APIs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Productivity tools&lt;/strong&gt; – Let AI handle tasks like email, calendars, or file management.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Custom workflows&lt;/strong&gt; – Build domain-specific tools (finance, healthcare, legal) that AI can call safely.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Getting Started With MCP Servers&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you’re a developer looking to experiment:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Check existing MCP server implementations&lt;/strong&gt; – Many open-source projects are popping up.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Build your own server&lt;/strong&gt; – If you’ve got an API or tool you want AI to use, wrapping it in an MCP server is straightforward.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Connect it to an MCP-compatible client&lt;/strong&gt; – This could be your own app or a platform that supports MCP out of the box.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The protocol itself is still evolving, but it’s rapidly gaining traction because it solves a real pain point: making AI useful with your tools and data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The real power of AI comes not just from reasoning but from action—actually using the tools and data you rely on. MCP servers are the backbone of that action layer, giving models a safe, standard way to plug into the world.&lt;/p&gt;

&lt;p&gt;If you’re building AI-powered apps or workflows, MCP isn’t just a buzzword. It’s a practical standard that could become the glue between your tools and the next generation of intelligent systems.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>php</category>
      <category>codenewbie</category>
      <category>laravel</category>
    </item>
    <item>
      <title>What is n8n? A Complete Beginner’s Guide to Workflow Automation</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Thu, 28 Aug 2025 05:11:52 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/what-is-n8n-a-complete-beginners-guide-to-workflow-automation-1jg8</link>
      <guid>https://dev.to/snehalkadwe/what-is-n8n-a-complete-beginners-guide-to-workflow-automation-1jg8</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello Artisans,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In today's blog post, we will explore what n8n is and how we can automate our day-to-day tasks by automating these Workflows. &lt;br&gt;
For example, we move data between apps, send repetitive emails, or double-check if we remembered to update a spreadsheet or not. It’s a boring, time-consuming task, and (let’s be honest) easy to mess up.&lt;/p&gt;

&lt;p&gt;That’s exactly the kind of work n8n was built to eliminate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is n8n?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;n8n (pronounced “n-eight-n”) is an open-source workflow automation tool. Think of it as a universal connector: it lets your apps, databases, and APIs talk to each other so you don’t have to.&lt;/p&gt;

&lt;p&gt;Unlike other automation tools, n8n gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Full Control&lt;/strong&gt; → Self-host it or use n8n.cloud.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flexibility&lt;/strong&gt; → Build simple workflows or advanced ones with conditions, loops, and custom code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Community Power&lt;/strong&gt; → Tons of integrations, all improving thanks to open source contributors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability Without Big Bills&lt;/strong&gt; → You’re not stuck paying per “zap” or “scenario.”&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How It Works?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;n8n uses a visual editor where you build workflows by dragging and connecting “nodes.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Triggers:&lt;/strong&gt; Events that start a workflow (like a new email or form submission).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Actions:&lt;/strong&gt; The steps that happen next (send a Slack message, update Google Sheets, create a task in Notion, etc.).&lt;/p&gt;

&lt;p&gt;It’s like playing with digital Lego blocks—easy to start, endlessly customizable.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Example: Your First Workflow&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let’s say you want to get notified in Slack whenever someone fills out a Typeform survey. Here’s how:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Add a Trigger Node&lt;/strong&gt; → Select Typeform as your trigger. Now every time someone fills your form, n8n knows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Add an Action Node&lt;/strong&gt; → Select Slack. Connect your workspace and choose the channel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Customize the Message&lt;/strong&gt; → Pull in form responses dynamically (like name, email, or feedback).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Save &amp;amp; Activate&lt;/strong&gt; → Boom—your Slack lights up instantly when a new response comes in.&lt;/p&gt;

&lt;p&gt;No more refreshing Typeform. No more copy-pasting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Other Cool Use Cases&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Marketing Teams&lt;/strong&gt; → Sync leads from landing pages straight into your CRM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developers&lt;/strong&gt; → Auto-create GitHub issues when errors show up in logs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Freelancers&lt;/strong&gt; → Automate invoicing reminders or onboarding emails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Everyday Life&lt;/strong&gt; → Get a daily digest of your tasks, news, or even crypto prices.&lt;/p&gt;

&lt;p&gt;If you find yourself repeating a process more than twice, chances are n8n can automate it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Try the hosted version: n8n.cloud or self-host with Docker or npm (great for developers who want full control).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explore templates from the n8n community for ready-made workflows.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Automation isn’t just about saving time—it’s about freeing your brain from the stuff that doesn’t spark joy. With n8n, you can finally stop being the “human API” between your tools and let them work together on autopilot.&lt;/p&gt;

&lt;p&gt;So if you’ve been curious about automation but want something flexible, affordable, and open, you will probably fall in love with n8n.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Reading!!&lt;/strong&gt;&lt;br&gt;
🦄❤️&lt;/p&gt;

</description>
      <category>ai</category>
      <category>codenewbie</category>
      <category>programming</category>
      <category>php</category>
    </item>
    <item>
      <title>Building a Cartoon Avatar Generator with Google AI Studio</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Mon, 04 Aug 2025 19:07:52 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/building-a-cartoon-avatar-generator-with-google-ai-studio-3o9n</link>
      <guid>https://dev.to/snehalkadwe/building-a-cartoon-avatar-generator-with-google-ai-studio-3o9n</guid>
      <description>&lt;p&gt;&lt;em&gt;This post is my submission for &lt;a href="https://dev.to/deved/build-apps-with-google-ai-studio"&gt;DEV Education Track: Build Apps with Google AI Studio&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;I set out to build a single-page React web app that generates personalized cartoon avatars from simple text descriptions. The key prompt I used was: “Build a React app that converts user descriptions like ‘young woman with glasses and curly hair’ into cartoon-style avatars with bold outlines and clean lines.” I automatically enhanced prompts with styling instructions, such as “cartoon style, bold outlines, simple shapes, expressive facial features,” and added features for background color selection and accessory options. The app utilizes the Imagen API for image generation and features native Web Share functionality for seamless sharing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://aistudio.google.com/app/prompts?state=%7B%22ids%22:%5B%221yPt8IB2jDx0Z__HbnZuwDmn9Y5JEhJWV%22%5D,%22action%22:%22open%22,%22userId%22:%22102412757949966579517%22,%22resourceKeys%22:%7B%7D%7D&amp;amp;usp=sharing" rel="noopener noreferrer"&gt;Cartoon Avatar Generator&lt;/a&gt; right now, I don't have the budget to deploy/share production ready app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/snehalkadwe/ai-cartoon-avatar-generator" rel="noopener noreferrer"&gt;Github Link&lt;/a&gt;&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%2Fpwborguil234cctaf8ce.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%2Fpwborguil234cctaf8ce.png" alt="Demo Image 1" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My Experience
&lt;/h2&gt;

&lt;p&gt;This project is the perfect example of how AI can accelerate creative web development. I learned the importance of prompt engineering—specifically how adding detailed styling instructions improved image quality dramatically. The Imagen API delivered fast, professional-looking results that matched the prompt perfectly. Adding user customization for backgrounds and accessories made the app feel more personal and engaging. Implementing native Web Share was surprisingly straightforward and added great usability. &lt;/p&gt;

&lt;p&gt;Overall, this experience showed me how modern AI tools and web APIs can turn ideas into polished apps quickly and efficiently.&lt;/p&gt;

</description>
      <category>deved</category>
      <category>learngoogleaistudio</category>
      <category>ai</category>
      <category>gemini</category>
    </item>
    <item>
      <title>Laravel 12 &amp; Laravel Cloud: The Next Big Leap in Web Development</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Wed, 26 Feb 2025 06:05:37 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/laravel-12-laravel-cloud-the-next-big-leap-in-web-development-h0l</link>
      <guid>https://dev.to/snehalkadwe/laravel-12-laravel-cloud-the-next-big-leap-in-web-development-h0l</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello Artisans,&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;I hope you are doing great. Today's blog post is all about Laravel's echo system.&lt;/p&gt;

&lt;p&gt;On &lt;strong&gt;February 24, 2025&lt;/strong&gt;, the Laravel community celebrated a significant milestone with the release of Laravel 12. This version introduced several groundbreaking features designed to enhance developer productivity and application performance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Native WebSocket Support with Laravel Echo&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Enhanced Event Broadcasting&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Streamlined Directory Structure&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;GraphQL API Integration&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Performance and Security Enhancements&lt;/em&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Along with this release of Laravel 12, the Laravel team unveiled several exciting developments to enhance the framework and its ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;New Laravel Website Launch&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The official Laravel website received a comprehensive redesign. The revamped site offers a more intuitive navigation experience, improved accessibility, and a modern aesthetic that reflects Laravel's commitment to innovation and developer satisfaction. The new updated design ensures that both newcomers and seasoned developers can easily access documentation, tutorials, and community resources.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Enhanced Starter Kits&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It also introduces new application starter kits for React, Vue, and Livewire. These kits utilize modern technologies such as Inertia 2, TypeScript, shadcn/ui, and Tailwind CSS, providing developers with a solid foundation for building dynamic applications. &lt;/p&gt;

&lt;p&gt;The Livewire starter kit, in particular, leverages the Flux UI component library and Laravel Volt, streamlining the development of reactive, server-driven interfaces. &lt;/p&gt;

&lt;p&gt;Additionally, each starter kit offers a variant powered by WorkOS AuthKit, enabling social authentication, passkeys, and SSO support. WorkOS provides free authentication for applications with up to 1 million monthly active users. &lt;/p&gt;

&lt;p&gt;You can read more about it &lt;a href="https://laravel.com/docs/12.x/starter-kits" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://react-starter-kit-main-trfk6v.laravel.cloud/" rel="noopener noreferrer"&gt;React Starter Kit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vue-starter-kit-main-jvxppc.laravel.cloud/" rel="noopener noreferrer"&gt;Vue&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://livewire-starter-kit-main-spxvec.laravel.cloud/" rel="noopener noreferrer"&gt;Livewire&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Another, big release was Laravel Cloud.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Laravel Cloud is a fully managed infrastructure platform that will make it easy to deploy and scale Laravel applications, enabling developers to concentrate on feature development rather than server complexity. &lt;br&gt;
Its arrival is a milestone addition to the Laravel ecosystem. It provides a smooth and streamlined solution for hosting and managing applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Key Features of Laravel Cloud&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Easy Deployment:&lt;/strong&gt; Deploy Laravel apps within less than a minute with no setup. By linking your Git provider and choosing the repository, Laravel Cloud takes care of deployment for you, bypassing manual configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automatic Scaling:&lt;/strong&gt; Laravel Cloud provides integrated autoscaling to deal with changing traffic loads. The platform scales resources automatically, guaranteeing peak performance without manual configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Managed Services:&lt;/strong&gt; The service offers managed databases, caching, and object storage. This integration enables developers to integrate these services directly into their applications without maintenance and configuration overhead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Improved Security:&lt;/strong&gt; Laravel Cloud prioritizes security through automated provisioning of SSL certificates, firewall settings, and DDoS protection. These options secure applications against identified threats and vulnerabilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaborative Features:&lt;/strong&gt; Created for individual developers and teams, Laravel Cloud provides team collaboration features. Users can invite team members, set permissions, and view application metrics in a group.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pricing Plans&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Flexible pricing available on Laravel Cloud for different project requirements:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hobby Plan:&lt;/strong&gt; Suitable for personal projects or small projects, the Hobby Plan delivers basic features at a low price.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Production Plan:&lt;/strong&gt; Best for professional usage, it supports features like custom domains, large instance sizes, longer log retention, and supporting more users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Business and Enterprise Plans:&lt;/strong&gt; Optimized for mass usage, they provide unlimited auto-scaling, dedicated compute power, and so on, and provide solid performance for high-demand applications.&lt;/p&gt;

&lt;p&gt;You can read more about Laravel Cloud from &lt;a href="https://cloud.laravel.com/?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Reading!&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Happy Coding!&lt;/strong&gt;&lt;br&gt;
🦄 ❤️&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>cloud</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Use Maatwebsite Excel in Laravel for Importing &amp; Exporting Data</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Sun, 23 Feb 2025 11:09:08 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/how-to-use-maatwebsite-excel-in-laravel-for-importing-exporting-data-2gac</link>
      <guid>https://dev.to/snehalkadwe/how-to-use-maatwebsite-excel-in-laravel-for-importing-exporting-data-2gac</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello Artisan,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This blog post will show how to implement import and export functionality in laravel applications using Maatwebsite Excel package.&lt;br&gt;
So let's get started with an introduction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Laravel, handling Excel files efficiently is crucial for data management tasks such as importing bulk records, generating reports, and exporting data. The Maatwebsite Excel package simplifies working with Excel files in Laravel applications. In this guide, we'll explore how to use this package to import and export data in Excel, with a small product-management application. Where we will have a list of products and each product belongs to a category.&lt;/p&gt;

&lt;p&gt;First, we will set up our laravel project, and add products and categories, with the help of a seeder which gives us some test data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Install and setup laravel project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;laravel&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;product&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;management&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During installation, you will be prompted with questions to set up your application. You can choose the options that best suit your preferences.&lt;br&gt;
I have selected no blade file, pest for testing, and MySQL database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Create model, migration, factory, and seeder for &lt;code&gt;Category&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="nc"&gt;Category&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;msf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Create a model, migration, factory, seeder, and Controller for the &lt;code&gt;Product&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="nc"&gt;Product&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;mcsf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Next step is to define migration and the relationship between Category and Products.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Open a migration file for &lt;code&gt;Category&lt;/code&gt; and add this code&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'categories'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'description'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;nullable&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamps&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Open a migration file for &lt;code&gt;Product&lt;/code&gt; and add the below code&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt; &lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'description'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;nullable&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'price'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;unsignedBigInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'category_id'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;foreign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'category_id'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;references&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'categories'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;onDelete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'cascade'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamps&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Now open a model files and add the following code:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Product.php&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;
    &lt;span class="cd"&gt;/**
     * The attributes that are mass assignable.
     *
     * @var array
     */&lt;/span&gt;
    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nv"&gt;$fillable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'description'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'price'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'category_id'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Get list of categories.
     *
     * @return BelongsTo
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;BelongsTo&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;belongsTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Category&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Category.php&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;    &lt;span class="cd"&gt;/**
     * The attributes that are mass assignable.
     *
     * @var array
     */&lt;/span&gt;
    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nv"&gt;$fillable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'description'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Get list of products.
     *
     * @return HasMany
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;HasMany&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hasMany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Now we will create and add test data with the help of the seeder.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CategoryFactory.php&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;faker&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'description'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;faker&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;sentence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ProductFactory.php&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;faker&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'description'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;faker&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;sentence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'price'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;faker&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;randomFloat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="s1"&gt;'category_id'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Category&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CategorySeeder.php&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Category&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Creates 5 random categories&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ProductSeeder.php&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Category&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'category_id'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// Each category gets 5 products&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now add these seeder files to &lt;code&gt;DatabaseSeeder.php&lt;/code&gt; to generate test data in our database within the &lt;code&gt;run&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
            &lt;span class="nc"&gt;CategorySeeder&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nc"&gt;ProductSeeder&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; Now run the migration command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;migrate&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;seed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our basic and required setup is done, now we will start with how to use &lt;code&gt;Maatwebsite&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Install Maatwebsite Excel Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To install the package, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;composer&lt;/span&gt; &lt;span class="k"&gt;require&lt;/span&gt; &lt;span class="n"&gt;maatwebsite&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;excel&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installation, the package automatically registers the service provider and facade. Now we need to publish its configuration file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;vendor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;publish&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Maatwebsite\Excel\ExcelServiceProvider"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 8:&lt;/strong&gt; Creating an Import Class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;ProductsImport&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Product&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create &lt;code&gt;app/Imports/ProductsImport.php&lt;/code&gt;. Modify it as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;App\Imports&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;App\Models\Product&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Maatwebsite\Excel\Concerns\ToModel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Maatwebsite\Excel\Concerns\WithHeadingRow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductsImport&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;ToModel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;WithHeadingRow&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * @param array $row
     *
     * @return \Illuminate\Database\Eloquent\Product|null
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Find category by id&lt;/span&gt;
        &lt;span class="nv"&gt;$category&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;\App\Models\Category&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'category_id'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;\Exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Invalid category: '&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'category_id'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
            &lt;span class="s1"&gt;'name'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="s1"&gt;'description'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'description'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="s1"&gt;'price'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;is_numeric&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'price'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nb"&gt;floatval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'price'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'category_id'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 9:&lt;/strong&gt; Creating an Export Class&lt;/p&gt;

&lt;p&gt;To export data as an Excel file, create an export class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;export&lt;/span&gt; &lt;span class="nc"&gt;ProductsExport&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Product&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modify &lt;code&gt;app/Exports/ProductsExport.php&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;App\Exports&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;App\Models\Product&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Maatwebsite\Excel\Concerns\FromCollection&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Maatwebsite\Excel\Concerns\WithHeadings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Maatwebsite\Excel\Concerns\WithEvents&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductsExport&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;FromCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;WithHeadings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;WithEvents&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * @return \Illuminate\Support\Collection
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;collect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="c1"&gt;// Retrieve all products and include the related category name using eager loading&lt;/span&gt;
        &lt;span class="c1"&gt;// Chunk the results to avoid memory issues as the dataset grows&lt;/span&gt;
        &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'category'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$chunk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$products&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$chunk&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$products&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nv"&gt;$products&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
                    &lt;span class="s1"&gt;'ID'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s1"&gt;'Name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s1"&gt;'Description'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s1"&gt;'Price'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s1"&gt;'Category'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s1"&gt;'Created At'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Y-m-d H:i:s'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                    &lt;span class="s1"&gt;'Updated At'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;updated_at&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Y-m-d H:i:s'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                &lt;span class="p"&gt;]);&lt;/span&gt;
            &lt;span class="p"&gt;});&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$products&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Add custom headers
     *
     * @return array
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'ID'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'Name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'Description'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'Price'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'Category'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'Created At'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'Updated At'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Apply styles to the headings
     *
     * @return array
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;registerEvents&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="nc"&gt;\Maatwebsite\Excel\Events\AfterSheet&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;\Maatwebsite\Excel\Events\AfterSheet&lt;/span&gt; &lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nv"&gt;$headingCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
                &lt;span class="nv"&gt;$columnRange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'A1:'&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nc"&gt;\PhpOffice\PhpSpreadsheet\Cell\Coordinate&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;stringFromColumnIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$headingCount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;sheet&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getDelegate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$columnRange&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getFont&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setBold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 10:&lt;/strong&gt; Add export and import methods in a controller&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Controller&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'products.index'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;compact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Export products to excel file
     *
     * @return \Illuminate\Http\Response
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;export&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Excel&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;download&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ProductsExport&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'products.xlsx'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Import products from excel file
     *
     * @param Request $request
     * @return \Illuminate\Http\RedirectResponse
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'required|mimes:xlsx,csv'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

        &lt;span class="nc"&gt;Excel&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ProductsImport&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;back&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'success'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Products Imported Successfully!'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 11:&lt;/strong&gt; Define Routes&lt;/p&gt;

&lt;p&gt;In routes/web.php, add routes for importing and exporting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/products'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;ProductController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'index'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'products.index'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/products/import-users'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;ProductController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'import'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'products.import'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/products/export-products'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;ProductController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'export'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'products.export'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 12:&lt;/strong&gt; Create a simple blade form&lt;br&gt;
In your Blade file &lt;code&gt;(resources/views/products/index.blade.php)&lt;/code&gt;, add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;http-equiv=&lt;/span&gt;&lt;span class="s"&gt;"X-UA-Compatible"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"ie=edge"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Product Import &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; Export&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.tailwindcss.com"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;body&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-gray-100 flex items-center justify-center h-screen"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-white p-8 rounded-lg shadow-md w-96"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-xl font-semibold text-gray-700 text-center mb-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Import &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; Export Products&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;

            &lt;span class="c"&gt;&amp;lt;!-- Import Form --&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"{{ route('products.import') }}"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt; &lt;span class="na"&gt;enctype=&lt;/span&gt;&lt;span class="s"&gt;"multipart/form-data"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"space-y-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                @csrf
                &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"block"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-gray-700"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Upload File&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"file"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"file"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;
                        &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mt-2 block w-full px-3 py-2 border rounded-lg text-gray-700 bg-gray-50"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;

                &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;
                    &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"w-full bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700 transition"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    Import Products
                &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;

            &lt;span class="c"&gt;&amp;lt;!-- Export Button --&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mt-4 text-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"{{ route('products.export') }}"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-blue-600 hover:underline"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Export Products&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Using Maatwebsite Excel in Laravel simplifies Excel imports and exports. Whether you're handling large datasets or need quick CSV/Excel downloads, this package is an essential tool for Laravel developers. Try it out in your Laravel projects and streamline your data operations!&lt;/p&gt;

&lt;p&gt;You can view the code on &lt;a href="https://github.com/snehalkadwe/product-management" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Reading&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Happy Coding&lt;/strong&gt;&lt;br&gt;
🦄 ❤️&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>A Guide to Git Conventional Commits</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Fri, 21 Feb 2025 17:22:04 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/a-guide-to-git-conventional-commits-35o6</link>
      <guid>https://dev.to/snehalkadwe/a-guide-to-git-conventional-commits-35o6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello Artisans,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In today's blog, we will see how to use a conventional commit message and why is good practice to use it. Let's say you are working on a project with multiple developers, you know how messy commit messages can become. Incompatible commit messages make tracking changes difficult, understanding the project's history, and automating releases. This is where Git Conventional Commits come in.&lt;/p&gt;

&lt;p&gt;Conventional Commits provide a structured format for writing commit messages. This process makes it easier to maintain a clean commit history, generate changelogs, and even automate versioning. In this blog, we'll explore the Conventional Commits specification, its benefits, and how you can integrate it into your workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Are Conventional Commits?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Conventional Commits are a lightweight convention for commit messages. They follow a structured pattern that provides meaningful information about the nature of a change. The basic syntax is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;optional&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;optional&lt;/span&gt; &lt;span class="nf"&gt;footer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;type&lt;/strong&gt;: Defines the purpose of the commit (e.g., feat, fix, docs, style).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;scope&lt;/strong&gt; (optional): Specifies the part of the codebase the change affects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;description&lt;/strong&gt;: A summary of the change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;body&lt;/strong&gt;(optional): A more detailed explanation of the commit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;footer(s)&lt;/strong&gt; (optional): Includes information such as breaking changes or issue references.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Common Commit Types&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here are the most commonly used commit types:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;feat&lt;/strong&gt;: Introduces a new feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;: feat(auth): add login functionality&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;fix&lt;/strong&gt;: Fixes a bug.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;: fix(ui): resolve button alignment issue&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;docs&lt;/strong&gt;: Updates documentation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;: docs(readme): update installation steps&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;style&lt;/strong&gt;: Changes that do not affect functionality (e.g., formatting, linting).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;: style(css): apply consistent spacing&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;refactor&lt;/strong&gt;: Code refactoring without changing behavior.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;: refactor(backend): improve API response handling&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;test&lt;/strong&gt;: Adds or modifies tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;: test(api): add unit tests for user routes&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;chore&lt;/strong&gt;: Miscellaneous changes like dependency updates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;: chore(deps): update eslint to v8.5.0&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Benefits of Using Conventional Commits&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Improved Readability:&lt;/strong&gt; Consistent commit messages make it easier to understand changes at a glance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Better Collaboration:&lt;/strong&gt; Teams can quickly identify changes relevant to their work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Automated Changelogs:&lt;/strong&gt; Tools like standard version and semantic release can generate changelogs automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Versioning &amp;amp; Releases:&lt;/strong&gt; Following Conventional Commits helps automate semantic versioning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Enhanced Code Reviews:&lt;/strong&gt; Clear commit messages to improve the code review process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Use of Conventional Commits can significantly improve your development workflow by enforcing consistency, enhancing the documentation process, and enabling automation. Following a structured commit format makes it easier for humans and tools to understand and process your project's history.&lt;/p&gt;

&lt;p&gt;Start using Conventional Commits today, and experience a cleaner, more efficient version control system! You can read more about it &lt;a href="https://www.conventionalcommits.org/en/v1.0.0/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Coding!&lt;br&gt;
Happy Reading!&lt;/strong&gt;&lt;br&gt;
❤️ 🦄&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>git</category>
      <category>github</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to Create a Package in Laravel</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Sat, 15 Feb 2025 18:12:04 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/how-to-create-a-package-in-laravel-4m0j</link>
      <guid>https://dev.to/snehalkadwe/how-to-create-a-package-in-laravel-4m0j</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello Artisan,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Laravel is one of the most popular PHP frameworks, and its modular nature allows developers to create reusable packages. A package is a self-contained bundle of reusable code that can be shared and installed across multiple Laravel projects. &lt;/p&gt;

&lt;p&gt;In this guide, we will walk you through creating a Laravel package from scratch for user-management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Set Up a New Laravel Package&lt;/strong&gt;&lt;br&gt;
Before starting, make sure you have Laravel installed. You can create a Laravel package in two ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Inside an existing Laravel application - (useful for testing while developing).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As a standalone package - (useful for distributing to others via Packagist).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Create a Directory for the Package&lt;/strong&gt;&lt;br&gt;
Navigate to your Laravel project’s &lt;code&gt;packages&lt;/code&gt; directory (if it doesn’t exist, create it):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="n"&gt;packages&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;laravelusermanager&lt;/span&gt;
&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="n"&gt;packages&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;laravelusermanager&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Initialize Composer&lt;/strong&gt;&lt;br&gt;
Run the following command inside the package directory to initialize Composer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;composer&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Define the Package in &lt;code&gt;composer.json&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
In your package’s &lt;code&gt;composer.json&lt;/code&gt;, ensure it includes the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"laraelusermanager"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"description"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"A sample Laravel package for user management"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"library"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"autoload"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"psr-4"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s2"&gt;"LaravelUserManager&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;LaravelUserManager&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"src/"&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="s2"&gt;"require"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"php"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;gt;=8.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"illuminate/support"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"^10.0"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Register the Package in Laravel&lt;/strong&gt;&lt;br&gt;
In your Laravel application, add your package’s namespace to &lt;code&gt;composer.json&lt;/code&gt; in the root project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="s2"&gt;"autoload"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"psr-4"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"LaravelUserManager&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;LaravelUserManager&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"packages/laravelusermanager/src/"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;composer dump-autoload&lt;/code&gt; to reload the autoload files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Create the Package Structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Inside &lt;code&gt;packages/laravelusermanager/,&lt;/code&gt; create the following directories:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;routes&lt;/span&gt; &lt;span class="n"&gt;resources&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;1. Create the Service Provider&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a file &lt;code&gt;src/PackageServiceProvider.php&lt;/code&gt; and define the service provider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;VendorName\LaravelUserManager&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Support\ServiceProvider&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PackageServiceProvider&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;ServiceProvider&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;boot&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Load routes&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;loadRoutesFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;__DIR__&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'/../routes/web.php'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Load views&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;loadViewsFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;__DIR__&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'/../resources/views'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'laravelusermanager'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Publish config&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;publishes&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
            &lt;span class="k"&gt;__DIR__&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'/../config/config.php'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;config_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'laravelusermanager.php'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;register&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Merge package config&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;mergeConfigFrom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;__DIR__&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'/../config/config.php'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'laravelusermanager'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Define Routes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;routes/web.php&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Support\Facades\Route&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;LaravelUserManager\Controllers\UserController&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'users'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;UserController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Create a Configuration File&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;config/config.php:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'setting'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'default_value'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Create a View&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;resources/views/users/index.blade.php&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;User List&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;ID&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Name&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Email&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    @foreach ($users as $user)
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;{{ $user-&amp;gt;id }}&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;{{ $user-&amp;gt;name }}&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;{{ $user-&amp;gt;email }}&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    @endforeach
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Create a Controller&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;src/Controllers/UserController.php&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;LaravelUserManager\LaravelUserManager\Controllers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Http\Request&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;App\Models\User&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Routing\Controller&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Controller&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'laravelusermanager::users.index'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;compact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'users'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'laravelusermanager::users.create'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;redirect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'users.index'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Register the Package in Laravel&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;config/app.php&lt;/code&gt;, add the service provider to the providers array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="s1"&gt;'providers'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nc"&gt;LaravelUserManager\PackageServiceProvider&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Test the Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;php artisan serve&lt;/code&gt; and visit &lt;code&gt;http://localhost:8000/users&lt;/code&gt;. You should see the list of users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Publishing the Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to share your package with others: Push your code to GitHub.&lt;/p&gt;

&lt;p&gt;Submit it to &lt;a href="https://packagist.org/" rel="noopener noreferrer"&gt;Packagist&lt;/a&gt; by registering it in your Composer account.&lt;/p&gt;

&lt;p&gt;To install it in other Laravel projects, use: &lt;br&gt;
&lt;code&gt;composer require laravelusermanager&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Creating a Laravel package is a great way to modularize and reuse code. By following these steps, you can build and distribute your own Laravel packages efficiently!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Reading!&lt;br&gt;
Happy Coding!&lt;/strong&gt;&lt;br&gt;
❤️ 🦄&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>beginners</category>
      <category>womenintech</category>
    </item>
    <item>
      <title>Build a Bug-Free Applications using Laravel Unit Testing</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Mon, 30 Dec 2024 18:26:04 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/step-by-step-laravel-unit-testing-build-bug-free-applications-4fek</link>
      <guid>https://dev.to/snehalkadwe/step-by-step-laravel-unit-testing-build-bug-free-applications-4fek</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello Artisan,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Testing is a part of software development. It ensures your application is working as expected. Laravel has good support for testing, and it was designed with testing in mind. It provides &lt;code&gt;Pest&lt;/code&gt; and &lt;code&gt;PHPUnit&lt;/code&gt; for testing. &lt;/p&gt;

&lt;p&gt;Once you install any laravel application you can see &lt;code&gt;phpunit.xml&lt;/code&gt; already available in your application. By default application contains two separate directories in &lt;code&gt;test&lt;/code&gt; directory one is for &lt;code&gt;Feature&lt;/code&gt; and another is &lt;code&gt;Unit&lt;/code&gt;. &lt;code&gt;Unit&lt;/code&gt; is a smaller and isolated part of your application while &lt;code&gt;Feature&lt;/code&gt; is used to test a larger part of your applications.&lt;/p&gt;

&lt;p&gt;In this blog post, we will explore how to write tests using &lt;strong&gt;PHPUnit&lt;/strong&gt; and how to integrate with your laravel application. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Why Unit Testing Matters?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Before getting into the details, let's quickly get a sense of why unit testing is important:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code Quality:&lt;/strong&gt; Tests catch bugs early in the game, thereby not risking them entering production.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Refactoring Confidence:&lt;/strong&gt; Tests allow you to refactor with confidence because you don't fear breaking functionality.&lt;br&gt;
Documentation: Tests act as living documentation for the behavior of your code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaboration&lt;/strong&gt;: They serve as a safety net for teams: they do not allow new changes to disrupt existing functionality.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before we start writing the test cases, ensure you have installed the Laravel application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Development environment is set up:&lt;/strong&gt; Create a &lt;code&gt;.env.testing&lt;/code&gt; file in the root directory of your project. This file is used instead of the &lt;code&gt;.env&lt;/code&gt; file when you are running PHPUnit tests or executing Artisan commands with the &lt;code&gt;--env=testing&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify PHPUnit Configuration:&lt;/strong&gt; Check the &lt;code&gt;phpunit.xml&lt;/code&gt; file in your project root. This file configures &lt;code&gt;_PHPUnit_&lt;/code&gt; for your Laravel application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run the Default Tests:&lt;/strong&gt; Laravel includes some example tests. You can run them using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;  &lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command executes all tests in the tests directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;So let's start writing Your First Unit Test&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature:&lt;/strong&gt; For testing larger chunks of your application, often involving HTTP requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unit:&lt;/strong&gt; For testing individual classes and methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Let’s write a simple unit test:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a Test File&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use Artisan to generate a test file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="nc"&gt;SumOfTwoNumberTest&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;unit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create &lt;code&gt;tests/Unit/SumOfTwoNumberTest.php&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Write a Test Case&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open the newly created test file and add your test logic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;Tests\Unit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;PHPUnit\Framework\TestCase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SumOfTwoNumberTest&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;TestCase&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cd"&gt;/**
     * A basic unit test example.
     *
     * @return void
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;test_addition&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertEquals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$sum&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Run the Test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run your test using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;vendor&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;phpunit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the &lt;code&gt;test&lt;/code&gt; Artisan command to run your tests. This command provides verbose test reports to ease the development and debugging process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see an output indicating whether the test passed or failed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;Testing a Laravel Model&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s create a unit test for a Laravel model method. Assume we have a &lt;code&gt;User&lt;/code&gt; model with a method &lt;code&gt;getFullName&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Model Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add the method to your User model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getFullName&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;first_name&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;last_name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Create the Test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Generate a test file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="nc"&gt;UserTest&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;unit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Edit the test file to test the &lt;code&gt;getFullName&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;Tests\Unit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;App\Models\User&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;PHPUnit\Framework\TestCase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserTest&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;TestCase&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;test_get_full_name&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;first_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'John'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;last_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Doe'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertEquals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'John Doe'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getFullName&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Execute the Test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run the test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see a success message if the method works as expected.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;Writing a Feature Test&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feature tests in Laravel allow you to test larger parts of your application, such as routes, controllers, and middleware. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let’s write an example feature test for a login page.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Generate a Feature Test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use Artisan to create a new feature test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;make&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="nc"&gt;LoginTest&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create &lt;code&gt;tests/Feature/LoginTest.php&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Write the Test Logic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open &lt;code&gt;LoginTest.php&lt;/code&gt; file and add the below code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;Tests\Feature&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Foundation\Testing\RefreshDatabase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Tests\TestCase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LoginTest&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;TestCase&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;RefreshDatabase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Test login page loads successfully.
     *
     * @return void
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;test_login_page_is_accessible&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/login'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertSee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Login'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cd"&gt;/**
     * Test users can login with valid credentials.
     *
     * @return void
     */&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;test_user_can_login_with_valid_credentials&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
            &lt;span class="s1"&gt;'password'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;bcrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'password123'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;

        &lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/login'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'password'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'password123'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;

        &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertRedirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/home'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertAuthenticatedAs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Run the Feature Test&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will show whether the login page is accessible and if the user can log in successfully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Some best practices for writing Unit Test in Laravel&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Descriptive Test Names:&lt;/strong&gt; The names of the tests should be very descriptive of what is being tested.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test One Thing at a Time:&lt;/strong&gt; Every test should test only one functionality or behavior.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Factories and Seeders:&lt;/strong&gt; Make use of Laravel's model factories and seeders to create test data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Isolate Tests:&lt;/strong&gt; Unit tests should not depend on external services such as a database or an API. Use mocks and stubs when necessary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can check Laravel &lt;a href="https://laravel.com/docs/11.x/testing#introduction" rel="noopener noreferrer"&gt;documentation &lt;/a&gt; for more details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
Unit and feature testing in Laravel are powerful ways to maintain code quality and ensure robust application behaviour. With the help of Laravel's &lt;code&gt;PHPUnit&lt;/code&gt; writing and running tests is straightforward and efficient. Integrating tests into your development process will create more reliable, maintainable applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Reading!!&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Happy Coding!!&lt;/strong&gt;&lt;br&gt;
❤️ 🦄&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>beginners</category>
      <category>womenintech</category>
    </item>
    <item>
      <title>Step-by-Step Guide: Running LLM Models with Ollama</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Sat, 21 Dec 2024 17:54:22 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/how-to-setup-ollma-and-llm-4601</link>
      <guid>https://dev.to/snehalkadwe/how-to-setup-ollma-and-llm-4601</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello Artisan,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In today's blog post, we will learn about Ollama, its key features, and how to install it on different OS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Ollama?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ollama is an open-source tool that allows you to run a &lt;code&gt;Large Language Model&lt;/code&gt; (LLM) on your local machine. It has vast collections of LLM models. It ensures privacy and security of data making it a more popular choice among AI developers, researchers, and business owners who prioritize data confidentiality.&lt;/li&gt;
&lt;li&gt;Ollama provides full ownership of your data and avoids potential risk.&lt;/li&gt;
&lt;li&gt;Ollama is an offline tool that reduces latency and dependency on external servers, making it faster and more reliable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Features of Ollama:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Management of AI model&lt;/strong&gt;: It allows you to easily manage all its models on your system by giving you full control over it to download, run, and remove models from your systems. It also maintains the version of each model installed on your machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Command Line Interface (CLI):&lt;/strong&gt; We operate on CLI to pull, run, and manage the LLM models locally. For users who prefer a more visual experience, it also supports third-party graphical user interface (GUI) tools like &lt;a href="https://openwebui.com/" rel="noopener noreferrer"&gt; Open WebUI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Multi-platform support:&lt;/strong&gt; Ollama offers cross-platform compatibility that includes Windows, Linux, and MacOS, making it easy to integrate into your existing workflows, no matter which operating system you use. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;How to use Ollama on multiple platforms&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this section, we will see how to download, install, and run Ollama locally on cross-platforms. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To download Ollma visit its official website &lt;a href="https://ollama.com/download" rel="noopener noreferrer"&gt;here&lt;/a&gt; and download it as per your preferred operating system. &lt;/li&gt;
&lt;li&gt;The installation process for MacOS is similar to Windows and for Linux, you have to run a command to install Ollama on your system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;I will walk you through the installation process for Windows, which you can follow similarly for macOS.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click the download button for your preferred OS to download an executable file. Then, open the file to start the installation process.&lt;/li&gt;
&lt;/ul&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%2F4rwdut2wyo0hih49ms37.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%2F4rwdut2wyo0hih49ms37.png" alt=" " width="425" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To install it on Linux, open a terminal and run the following command to install Ollama on your machine.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;curl&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;fsSL&lt;/span&gt; &lt;span class="nx"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//ollama.com/install.sh | sh&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Yeah!, you have successfully installed Ollama. It will be in a tray of your system showing it was running&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Now we will see how to use, and download different models provided by Ollama with the help of the &lt;em&gt;&lt;code&gt;Command Line Interface&lt;/code&gt;&lt;/em&gt; (CLI).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your terminal and follow these steps. &lt;a href="https://ollama.com/search" rel="noopener noreferrer"&gt;Here&lt;/a&gt; is a list of LLM models provided by Ollama.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;ollama&lt;/strong&gt;: this command will list all the available commands.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ollama -v or --version&lt;/strong&gt;: display the version&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ollama list&lt;/strong&gt;: list all the models installed in your systems&lt;/li&gt;
&lt;/ol&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%2Fpydupxbplpanq1ncuc2v.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%2Fpydupxbplpanq1ncuc2v.png" alt=" " width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Now we will see how to install the model using Ollama&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The LLM model can be installed in two ways: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ollama pull model_name&lt;/li&gt;
&lt;li&gt;ollama run model_name - If the model is not already downloaded on the system, it will first pull the model and then run it&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;We will install &lt;code&gt;gemma2&lt;/code&gt; model in our system&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://ollama.com/library/gemma2" rel="noopener noreferrer"&gt;gemma2&lt;/a&gt;: Google Gemma 2 is a high-performing and efficient model available in three sizes: 2B, 9B, and 27B.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;ollama&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt; &lt;span class="nx"&gt;gemma2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will open a prompt to write a message like below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;Send a message &lt;span class="o"&gt;(&lt;/span&gt;/? &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="nb"&gt;help&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We have to write our prompt here, which returns the response.&lt;/li&gt;
&lt;li&gt;To exit from the model we have to write &lt;strong&gt;/bye&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&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%2Fs06felaex73vtdsge7la.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%2Fs06felaex73vtdsge7la.png" alt=" " width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can now use any model provided by Ollama in these. Explore the model and try to use it as per your need.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
We have explored Ollama, an open-source tool that allows you to run LLM models locally, unlike other tools that rely on cloud servers. Ollama ensures data security and privacy, and we've learned how to run and use it on your local machine. It offers a simple and straightforward way to run LLM models effortlessly, directly on your system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Reading!&lt;br&gt;
Happy Coding!&lt;/strong&gt;&lt;br&gt;
🦄 ❤️&lt;/p&gt;

</description>
      <category>programming</category>
      <category>ai</category>
      <category>php</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Using Docker with Laravel Sail</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Thu, 05 Dec 2024 16:47:38 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/using-docker-with-laravel-sail-29hp</link>
      <guid>https://dev.to/snehalkadwe/using-docker-with-laravel-sail-29hp</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello Artisans,&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Laravel Sail is a lightweight command-line interface (CLI) used for interacting with Laravel's default Docker environment. It provides developers an easy way to get started with Laravel in a fully containerized development environment without the hassle of manually setting up services like MySQL, Redis, or a queue worker in docker container.&lt;/p&gt;

&lt;p&gt;In this guide, I'll walk you through the process of setting up and using Laravel Sail, highlighting its key features and benefits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Laravel Sail?&lt;/strong&gt;&lt;br&gt;
Laravel Sail is a Docker development environment for Laravel. It includes everything you need to start building Laravel applications, such as PHP, MySQL, Redis, and more. Sail is particularly useful because it abstracts Docker complexities, allowing developers to focus on building applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
Before we start how to use Laravel Sail, make sure you have these setup in your machine:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Docker installed:&lt;/strong&gt; Download and install Docker from its official website.&lt;br&gt;
&lt;strong&gt;2. Composer:&lt;/strong&gt; Laravel Sail requires Composer to install dependencies. You can download Composer from &lt;code&gt;getcomposer.org&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I hope you have installed all the requirements. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Guide to Using Laravel Sail&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install a New Laravel Project&lt;/strong&gt;&lt;br&gt;
Run the following command to create a new Laravel application and include Sail in your project dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;composer&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="n"&gt;laravel&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;laravel&lt;/span&gt; &lt;span class="n"&gt;laravel&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sail&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;
&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="n"&gt;laravel&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sail&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: The next step is to install Laravel Sail in your project.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;composer&lt;/span&gt; &lt;span class="k"&gt;require&lt;/span&gt; &lt;span class="n"&gt;laravel&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;sail&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the installation is finished, we need to publish its Docker configuration files. You can do it by running the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;sail&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; When a prompt appears you need to select your required services such as MySQL, Redis, or PostgreSQL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Start the Sail Environment&lt;/strong&gt;&lt;br&gt;
To start the development environment, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;vendor&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;sail&lt;/span&gt; &lt;span class="n"&gt;up&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sail up command will start all the necessary containers for your Laravel application. By default, Sail runs containers for PHP, MySQL, and Nginx.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Access Your Laravel Application&lt;/strong&gt;&lt;br&gt;
Once the Sail environment runs, you can access your application by navigating to &lt;code&gt;http://localhost in your browser&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Run Artisan Commands with Sail&lt;/strong&gt;&lt;br&gt;
Laravel Sail allows you to run Artisan commands seamlessly in the Docker environment. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;vendor&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;sail&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;migrate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also simplify your workflow by aliasing Sail:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;alias&lt;/span&gt; &lt;span class="n"&gt;sail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'[ -f sail ] &amp;amp;&amp;amp; bash sail || bash vendor/bin/sail'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can run commands like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;sail&lt;/span&gt; &lt;span class="n"&gt;up&lt;/span&gt;
&lt;span class="n"&gt;sail&lt;/span&gt; &lt;span class="n"&gt;artisan&lt;/span&gt; &lt;span class="n"&gt;migrate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6: Manage Containers&lt;/strong&gt;&lt;br&gt;
You can stop the containers with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;sail&lt;/span&gt; &lt;span class="n"&gt;down&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command shuts down the Docker containers, preserving data in volumes like your database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Customizing the Docker Configuration&lt;/strong&gt;&lt;br&gt;
The docker-compose.yml file generated by Laravel Sail is highly customizable. You can add or remove services, change environment variables, or tweak resource allocations.&lt;/p&gt;

&lt;p&gt;Now you are ready with a Docker container to interact with your laravel application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Using Laravel Sail&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Easy to Use:&lt;/strong&gt; Sail simplifies the Docker experience with straightforward commands.&lt;br&gt;
&lt;strong&gt;2. Preconfigured Environment:&lt;/strong&gt; Sail provides a preconfigured setup, saving you time during development.&lt;br&gt;
&lt;strong&gt;3. Cross-Platform Support:&lt;/strong&gt; Works seamlessly on Linux, macOS, and Windows (via WSL 2).&lt;br&gt;
&lt;strong&gt;4. Supports Multiple Services:&lt;/strong&gt; Easily integrate databases, caching layers, and queue workers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commonly used Sail Commands:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sail up&lt;/code&gt;:   Start the Docker containers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sail down&lt;/code&gt;: Stop the Docker containers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sail artisan&lt;/code&gt;: Run Artisan commands&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sail npm install&lt;/code&gt;: Install npm dependencies&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sail test&lt;/code&gt;: Run Laravel test suite&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sail mysql&lt;/code&gt;:    Access MySQL command-line interface&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
It's the best for developers who want to have a hassle-free development environment. Using the Docker-based approach, you can ensure consistency across all development machines, thus making collaboration easier. You will be able to set up and start using Laravel Sail to boost your productivity and focus on building great applications through this guide.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Reading!&lt;/strong&gt; 🦄 ❤️&lt;br&gt;
&lt;strong&gt;Happy coding!&lt;/strong&gt; 🦄 ❤️&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>docker</category>
      <category>php</category>
      <category>womenintech</category>
    </item>
    <item>
      <title>Hacktoberfest 2024: Contributing to Open Source and Growing as a Developer</title>
      <dc:creator>Snehal Rajeev Moon</dc:creator>
      <pubDate>Sun, 20 Oct 2024 14:08:37 +0000</pubDate>
      <link>https://dev.to/snehalkadwe/hacktoberfest-2024-contributing-to-open-source-and-growing-as-a-developer-4c8f</link>
      <guid>https://dev.to/snehalkadwe/hacktoberfest-2024-contributing-to-open-source-and-growing-as-a-developer-4c8f</guid>
      <description>&lt;p&gt;October is here and so is Hacktoberfest. It is one great reason to look forward to October every year for open-source enthusiasts, developers, and tech communities. &lt;/p&gt;

&lt;p&gt;It's been my second year and I am participating in different events organized by them. It is a month-long celebration of all things open source, where contributors are invited to improve, collaborate, and support open-source projects through learning, hands-on experiences, and rewarding participation. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Hacktoberfest?&lt;/strong&gt;&lt;br&gt;
Hacktoberfest began in 2014 and has become an annual event encouraging the tech community, which mainly comprises developers, to contribute to open-source projects. Organized by DigitalOcean in partnership with Cloudflare and Quira, this event allows developers to learn how to code, socialize with like-minded people, and give back to projects that make the modern internet go.&lt;/p&gt;

&lt;p&gt;In 2014, there were just 676 participants however in 2023 it has nearly 98,000 contributors! Hacktoberfest is just growing and has become a huge global celebration, which unifies all coders and open-source advocates from every corner of the world.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Participate&lt;/strong&gt;&lt;br&gt;
It is pretty easy to participate in Hacktoberfest. Whether you're a huge developer or just getting started, this is a great opportunity to give back to open-source development. Here's an extremely fast guide on how you can join in:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hacktoberfest.com/" rel="noopener noreferrer"&gt;Here &lt;/a&gt; is the link where you can sign up and start digging into the events that are suitable for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule:&lt;/strong&gt; You need to contribute at least four pull or merge requests to an open-source repository between October 1 and October 31. For those who want to sponsor or contribute to a project, make sure the issue includes "Hacktoberfest-accepted" so that there is no confusion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Be part of the Community on Discord:&lt;/strong&gt; Share your journey and catch up with other contributors in Discord. Ask for their guidance and so on; let everyone know you're making progress.&lt;/p&gt;

&lt;p&gt;Hacktoberfest is not just code; it's about the whole open-source ecosystem. Most sites are open source projects, so contributing to them means maintaining these critical technologies.&lt;/p&gt;

&lt;p&gt;It also allows you to take part by volunteering for open-source project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Participate?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Learn and Grow:&lt;/strong&gt; Contributing to open-source projects is a cool way to hone your technical skills, get real-world experience, improve your Git and GitHub skills, and learn how to collaborate with other developers.&lt;br&gt;
You connect, share knowledge, and even collaborate on projects under the mantle of Hacktoberfest, part of a global community.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Give back:&lt;/strong&gt; The open-source community gives so much to the world Hacktoberfest is your chance to give back by improving and supporting the projects that shape our digital landscape. &lt;br&gt;
You can also donate to open-source projects by supporting their work. Here is the link to &lt;a href="https://hacktoberfest.com/donate/" rel="noopener noreferrer"&gt;Donate&lt;/a&gt;, search the project you want to support and donate it.&lt;/p&gt;

&lt;p&gt;All the participants will be awarded with a digital badge. It is an opportunity to contribute back to the open source community which helps us to learn more new skills with like-minded people.&lt;/p&gt;

&lt;p&gt;Let's appreciate the power of collaboration, code, and community. &lt;br&gt;
Happy hacking!&lt;br&gt;
🦄 ❤️&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>hacktoberfest</category>
      <category>devchallenge</category>
    </item>
  </channel>
</rss>
