<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ritik on Medium]]></title>
        <description><![CDATA[Stories by Ritik on Medium]]></description>
        <link>https://medium.com/@ritik065?source=rss-711e7b438292------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qoEjwE7aVqxN99IBYgNSzQ.png</url>
            <title>Stories by Ritik on Medium</title>
            <link>https://medium.com/@ritik065?source=rss-711e7b438292------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 16:05:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ritik065/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[API Design: Basics to Best Practices]]></title>
            <link>https://ritik065.medium.com/api-design-basics-to-best-practices-10c6fba85e9b?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/10c6fba85e9b</guid>
            <category><![CDATA[practice]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[storytelling]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Thu, 10 Jul 2025 07:38:34 GMT</pubDate>
            <atom:updated>2025-07-10T07:38:34.850Z</atom:updated>
            <content:encoded><![CDATA[<h4>Since the inception of the HTTP protocol, web services have also been around. However, they are now the most common way to let customers to engage with services and data since the emergence of cloud computing.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cvNv3_v933f2U0bg" /><figcaption>Photo by <a href="https://unsplash.com/@rubaitulazad?utm_source=medium&amp;utm_medium=referral">Rubaitul Azad</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this informative tutorial, we will lead you through the fundamentals of API design, starting with the basics and proceeding to advanced best practices. By the end of this blog, you will have a thorough grasp of how to create APIs that are efficient, safe, and simple to use.</p><p>APIs are the foundation of modern software development. They allow distinct applications to communicate and share data in a smooth manner, allowing for successful integration of multiple systems and services. Whether you’re developing a basic API for a personal project or a complicated one for a large-scale business application, adhering to proper API design principles is essential for designing strong, scalable, and user-friendly interfaces.</p><h4><strong>Introduction</strong></h4><p>APIs (Application Programming Interfaces) provide communication between various software systems. A well-designed API is user-friendly, efficient, and simple to maintain. This article delves into the principles of API design, including recommended practices for ensuring stability, scalability, and usability.</p><p>APIs define how software components interact. They can be categorized into various types:</p><ol><li><strong>REST (Representational State Transfer)<br></strong>REST is a style for building web APIs that uses standard HTTP methods like GET, POST, PUT, and DELETE. It follows a <strong>stateless</strong> design, meaning the server doesn’t remember anything between requests.</li></ol><p><strong>Core Concepts:<br>Resources:</strong> Everything is treated as a resource (like /users, /orders).<br><strong>Stateless:</strong> Each request must include all the info the server needs; no session data is stored.<br><strong>Data Format:</strong> Responses usually come in JSON (sometimes XML).<br><strong>Scalable:</strong> Works well for large, distributed systems.</p><p><strong>HTTP Methods:<br></strong>GET → fetch data<br>POST → create new data<br>PUT/PATCH → update existing data<br>DELETE → remove data</p><p><strong>2. REST (Representational State Transfer)<br></strong>SOAP is a strict, rules-based protocol mainly used in large enterprises and banking systems. It’s all about standardization and security.</p><p><strong>What Stands Out:<br>Uses XML:</strong> Everything — requests and responses — is written in XML.<br><strong>Works Over Multiple Protocols:</strong> Can run over HTTP, SMTP, TCP, etc.<br><strong>Built-in Security:</strong> Includes WS-Security for secure transactions.<br><strong>WSDL Definitions:</strong> Uses formal contracts (WSDL files) to define API operations.<br><strong>Reliable but Heavy:</strong> Ensures consistent data delivery but adds overhead due to XML parsing and verbose metadata.</p><p><strong>3. GraphQL<br></strong>GraphQL is a flexible query language for APIs that lets clients ask exactly for the data they want — nothing more, nothing less.</p><p><strong>Key Features:<br>Single Endpoint:</strong> Everything runs through one /graphql URL.<br><strong>Precise Data Fetching:</strong> Clients decide what fields they want, reducing unnecessary data transfer.<br><strong>Typed Schema:</strong> The API has a strict schema, so clients know what to expect.<br><strong>Nested Queries:</strong> You can fetch related data in one go (e.g., user and their posts).<br><strong>Real-time Support:</strong> Supports live updates using <strong>subscriptions</strong>.<br><strong>Client-First:</strong> The frontend controls the shape of the response.</p><p><strong>4. RPC (Google Remote Procedure Call)<br></strong>gRPC is a fast, modern framework built for high-performance communication between services, especially in microservices.</p><p><strong>Why It’s Powerful:<br>Uses Protobuf:</strong> Instead of JSON, it uses Protocol Buffers (a compact binary format), which is smaller and faster.<br><strong>HTTP/2 Support:</strong> Enables bidirectional streaming — both client and server can send messages simultaneously.<br><strong>Strong Typing:</strong> Everything is defined clearly using .proto files.<br><strong>Fast &amp; Efficient:</strong> Perfect for high-throughput systems and real-time apps.<br><strong>Secure:</strong> Comes with built-in TLS encryption.<br><strong>Cross-Language:</strong> Works with many languages like Go, Java, Python, C++, etc.</p><h4>Principles of API Design</h4><ol><li><strong>Consistency<br></strong>A well-designed API requires consistent behavior. Make sure that your API’s structure, naming practices, and error handling are all consistent. For example:</li></ol><ul><li>Use similar naming conventions for endpoints.</li><li>Apply uniform formats for responses and errors.</li><li>Standardize parameter names and data types.</li></ul><p><strong>2. Statelessness<br></strong>Design your API to be stateless. Each client request should include all of the necessary information to complete it. This simplifies the server design and increases scalability. Statelessness indicates that the server does not retain any client context between requests, which aids in load balancing across different servers.</p><p><strong>3. Clarity and Consistency</strong></p><ul><li>Use clear, meaningful endpoint names (/users instead of /getAllUsers).</li><li>Follow consistent naming conventions (camelCase, snake_case, or kebab-case).</li><li>Use uniform error handling and response structures.</li></ul><p><strong>4. Versioning</strong></p><ul><li>Use versioning to avoid breaking changes (e.g., /v1/users).</li><li>Prefer URL-based (/v1/resource) or header-based (Accept-Version) versioning.</li></ul><p><strong>5. API Security Best Practices<br></strong>Securing APIs is crucial to protect data, maintain user trust, and prevent unauthorized access or malicious attacks. A robust security approach involves encrypting data, verifying identities, and strictly controlling what users can do based on their roles. Below are key practices to follow when designing and building secure APIs:</p><ul><li><strong>Use authentication and authorization:</strong> Implement standards like <strong>OAuth 2.0</strong>, <strong>JWT</strong>, or <strong>API keys</strong> to verify users and control access.</li><li><strong>Enforce HTTPS:</strong> Always encrypt data in transit to prevent eavesdropping or man-in-the-middle attacks.</li><li><strong>Validate and sanitize input:</strong> Prevent <strong>SQL injection</strong>, <strong>command injection</strong>, and other attacks by thoroughly checking all user inputs.</li><li><strong>Implement RBAC (Role-Based Access Control):</strong> Limit access to resources and actions based on user roles (e.g., admin, editor, viewer).</li><li><strong>Defend against CSRF and XSS:</strong> Use CSRF tokens and properly escape outputs to avoid malicious scripts running in browsers.</li></ul><p><strong>6. Pagination and Filtering</strong></p><ul><li>Implement pagination (?page=1&amp;limit=10) for large datasets.</li><li>Allow filtering (?status=active) to improve efficiency.</li><li>Use sorting (?sort=created_at,desc).</li></ul><p><strong>7. Rate Limiting and Caching</strong></p><ul><li>Implement rate limiting to prevent abuse (X-Rate-Limit headers).</li><li>Use caching strategies (ETags, Redis) to enhance performance.</li><li>Utilize Content Delivery Networks (CDNs) for faster API responses.</li></ul><p><strong>8. Error Handling Best Practices<br></strong>Effective error handling helps clients understand what went wrong and how to fix it. Use proper HTTP status codes and return consistent, meaningful JSON responses.</p><p><strong>Use appropriate HTTP status codes:</strong></p><ul><li>200 → OK (Success)</li><li>400 → Bad Request (Invalid input)</li><li>401 → Unauthorized (Missing or invalid auth)</li><li>403 → Forbidden (No permission)</li><li>404 → Not Found (Resource doesn’t exist)</li><li>500 → Internal Server Error (Server-side issue)</li></ul><h4>Advanced API Best Practices Every Developer Should Follow</h4><p>Designing APIs is no longer just about getting data from point A to B — it’s about security, reliability, scalability, and user trust. Whether you’re building a public-facing API or a microservice backend, these best practices are essential for modern, enterprise-grade development.</p><p><strong>1 Authentication and Authorization: Know Who’s Accessing What</strong></p><p>APIs must know <strong>who is making the request</strong> (authentication) and <strong>what they’re allowed to do</strong> (authorization). Security isn’t a feature — it’s a foundation.</p><p><strong>Modern API Authentication Techniques:</strong></p><ul><li><strong>OAuth 2.0</strong> — The industry-standard protocol for secure access delegation. Ideal for third-party integrations.</li><li><strong>JWT (JSON Web Tokens)</strong> — Self-contained tokens that include claims and signatures. Great for stateless and scalable APIs.</li><li><strong>API Keys</strong> — Simple tokens passed in headers or query params. Best for internal or low-security APIs.</li></ul><p><strong>2. Rate Limiting: Keep Abusers Out Without Penalizing Legit Users</strong></p><p>APIs need boundaries. Rate limiting ensures no single client overloads your system. It promotes fairness and protects your infrastructure.</p><p><strong>Pro tip:</strong> Implement rate limiting via <strong>API gateways</strong> like Kong or AWS API Gateway, or at the <strong>middleware level</strong>.</p><p><strong>3. Error Handling: Fail Loud, Fail Smart</strong></p><p>Clients love clarity. Instead of vague messages like “Something went wrong,” return well-structured, predictable error responses.</p><p><strong>Use standard HTTP status codes</strong> and provide detailed JSON error bodies:</p><pre>{<br>  &quot;error&quot;: {<br>    &quot;code&quot;: 404,<br>    &quot;message&quot;: &quot;Resource not found&quot;<br>  }<br>}</pre><p><strong>4. Pagination &amp; Filtering: Don’t Flood Clients with Data</strong></p><p>Returning thousands of records in one response? You’re asking for trouble. Implement <strong>pagination, filtering, and sorting</strong> to improve performance and reduce bandwidth.</p><ul><li><strong>Pagination:</strong> GET /posts?page=2&amp;limit=10</li><li><strong>Filtering:</strong> GET /posts?author=JohnDoe</li><li><strong>Sorting:</strong> GET /posts?sort=created_at&amp;order=desc</li></ul><p>Keep responses lean and flexible — clients will thank you (and so will your servers).</p><p><strong>5. Documentation: Your API is Only as Good as Its Docs</strong></p><p>You wouldn’t use an API without documentation — don’t expect others to either. Great APIs are <strong>self-descriptive and well-documented</strong>.</p><p><strong>Tools to Generate and Share Documentation:</strong></p><ul><li><strong>Swagger / OpenAPI</strong> – Define your API structure and auto-generate docs.</li><li><strong>Postman</strong> – For testing, publishing, and sharing interactive docs.</li><li><strong>Redoc / Stoplight</strong> – Beautiful, user-friendly doc UIs.</li></ul><p><strong>6. Monitoring &amp; Analytics: Don’t Fly Blind</strong></p><p>Once deployed, APIs need observability. Logging, monitoring, and usage analytics help you detect issues and optimize performance.</p><ul><li><strong>Prometheus + Grafana</strong> – Real-time metrics and visualizations.</li><li><strong>ELK Stack (Elasticsearch, Logstash, Kibana)</strong> – Powerful log search and analysis.</li><li><strong>New Relic / Datadog</strong> – Application-level performance monitoring.</li></ul><blockquote><strong>What to Monitor:<br></strong>Request counts and response times<br>Error rates and retry spikes<br>Latency bottlenecks<br>Unusual traffic patterns</blockquote><h3>Conclusion</h3><p>That’s a wrap! If you’ve made it this far, you now have a solid grip on the advanced practices that make APIs secure, reliable, and developer-friendly. I’ve tried to keep things practical and easy to digest so you can actually apply them in real projects, not just memorise theory. Whether you’re building something small or scaling a big system, these principles will keep your API game strong. Thanks for reading — now go build something awesome!</p><p>I hope this story adds some value to your new or existing application. I attempted to convey the basic notion. Thanks for reading this story If you find any mistakes, please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, you can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10c6fba85e9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to deploy Vue.js apps | Github Actions]]></title>
            <link>https://ritik065.medium.com/how-to-deploy-vue-js-apps-github-actions-fb36c8f08b13?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb36c8f08b13</guid>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 07:36:12 GMT</pubDate>
            <atom:updated>2025-04-23T07:36:12.821Z</atom:updated>
            <content:encoded><![CDATA[<h4>Vue.js auto-deployment to the server using GitHub Actions streamlines the deployment process, making a smooth CI/CD from the local machine to the server.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*_X3gGizj6G6U-antaq4OuA.png" /></figure><p>In this Story, you’ll learn how to automate the deployment of your Vue.js application to the server using GitHub Actions. We’ll walk through setting up GitHub workflows, integrating version control with Git, and making essential configurations to ensure smooth deployment. Along the way, you’ll gain practical insights into optimising your Vue.js setup for seamless production-ready deployment.</p><h4>What is GitHub Actions?</h4><p>GitHub actions are automated processes that enable you to host, test, and release software. It is an essential component of GitHub, facilitating the development process through push and automation activities. Simply put, GitHub actions navigate the instructions you create in your Git repository to automate the development process or an API for cause and effect.</p><p>Before you begin your development cycle, you need be aware of a few GitHub action components.</p><p><strong>Event</strong>: This is an activity in which the process is activated and the automated pipeline begins to pull or push requests.<br><strong>Workflow</strong>: Any event can initiate a workflow, indicating that automated processes will be used when the program is ready for release.<br><strong>Runner</strong>: The server that executes the workflow when it is triggered. Furthermore, each runner can be performed concurrently, and each process launches a new virtual computer. <br><strong>Actions</strong>:A custom application handles sophisticated yet often repeated activities. It is used to reduce repetitive tasks and prepare the environment.<br><strong>Jobs</strong>: A collection of steps that work in a specific order and rely on one another to share data. If it is not dependent on others, it will start a new job to package up the builds by default.<br><strong>YAML:</strong> (Yet Another Markup) is a human data serialization language. It defines the workflow using GitHub activities, and each workflow is saved as a distinct YAML syntax file in your code repository. For example, the directory may be named.github/workflows.</p><p>Now i assume your Vue app is ready to deploy, and you have all the basic requirements and your GitHub repo for the process.<br>Let’s start with the deployment process and setting up our Vue app</p><h4><strong>Direct Deployment</strong></h4><p>There is also a very easy but manual way to deploy a Vue app to the server by moving the build zip file to the server, this can be done by</p><pre>npm i. //to install all the required packages<br>npm run build // it will make a build ready for production</pre><p>After running the above commands, you will see files in the vueapp/dist folder. Make a zip of files under the dist folder and upload directly to the server. Then unzip or extract the zip file over there :)</p><h4>Deployment using GitHub Actions</h4><p>To do this, we need to make some changes in our Vue app directory</p><ol><li>Open Your Project in VS Code or any editor and create a folder called .scripts inside the root of the folder, e.g. vueProject/.scripts,</li><li>Inside the .scripts folder, Create A file with a .sh extension, e.g. vueProject/.scripts/deploy.sh and paste the below code there,</li></ol><pre>#!/bin/bash<br>set -e<br><br>echo &quot;Prodcution Deployment started &quot;<br><br># Pull the latest version of the app<br>git pull origin master<br>echo &quot;New changes pulled to server !&quot;<br><br>echo &quot;Installing Dependencies &quot;<br>npm install --yes<br><br>echo &quot;Creating Production Build &quot;<br>npm run build<br><br>echo &quot;Deployment Finished!&quot;</pre><p>3. Go inside .scripts Folder, then Set File permissions forthe .sh File</p><pre>git update-index --add --chmod=+x deploy.sh</pre><p>4. Now create a Directory Path named .github/workflows inside your root project folder e.g. vueProject/.github/workflows then inside this folder create a file deploy.yml, e.g. vueProject/.github/workflows/deploy.yml</p><p>5. In deploy.yml file copy the below code, make changes according to requirements.</p><pre>name: Deploy<br><br># Trigger the workflow on push and<br># pull request events on the master branch<br>on:<br>  push:<br>    branches: [&quot;master&quot;]<br>  pull_request:<br>    branches: [&quot;master&quot;]<br><br># Authenticate to the the server via ssh<br># and run our deployment script<br>jobs:<br>  deploy:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v3<br>      - name: Deploy to Production Server<br>        uses: appleboy/ssh-action@master<br>        with:<br>          host: ${{ secrets.HOST }}<br>          username: ${{ secrets.USERNAME }}<br>          port: ${{ secrets.PORT }}<br>          key: ${{ secrets.SSHKEY }}<br>          script: &quot;cd /var/www/project_folder &amp;&amp; ./.scripts/deploy.sh&quot;</pre><blockquote><em>make sure at the end of file you provide actual path to project by checking on your server else it will throw an error</em></blockquote><p>After successfully making changes in the project folder locally, <br><strong>It’s time to make changes in GitHub for this project repository</strong></p><p>Go to Github Repo of this project and click on settings, then Click on Secrets and Variables from the Sidebar then choose Actions after this click on add new secrets, we will be adding four secrets here that are being used in deploy.yml file.</p><pre>Name: HOST<br>Secret: Your_Server_IP<br><br>Name: PORT<br>Secret: Your_Server_PORT<br><br>Name: USERNAME<br>Secret: Your_Server_User_Name<br><br>Name: SSHKEY<br>Secret: Your_Server_SSHKEY</pre><p>If you don’t know the SSHKEY, don’t worry, we can generate a new one</p><pre>ssh-keygen -f .ssh/vueapp -t ed25519 -C &quot;your_email@example.com&quot;<br><br># If you’re in your home directory (~), it will create:<br> # ~/.ssh/vueapp → 🔒 Private Key<br> # ~/.ssh/vueapp.pub → 🔑 Public Key</pre><p>Open the Newly Created Public SSH Keys, then copy the key</p><pre>cat ~/.ssh/vueapp.pub</pre><p>Now, Open the authorized_keys File which is inside .ssh/authorized_keys, then paste the copied key in a new line at the end and close the file.</p><pre>cd .ssh<br>nano authorized_keys</pre><p>Till now, we have generated and added the public key to the authorized_keys. At the end, we will use the private key to add as secrets in <strong>GitHub Actions SSHKEY, </strong>Open Newly Created Private SSH Keys then copy the key</p><pre>cat ~/.ssh/vueapp</pre><blockquote>Before you start to test the changes, I highly recommend to ssh into your server and take a pull from your repo to server directory to make required files available on the server to execute deploy script and workflow. Probably you might see a permissions error on .scripts/deploy.sh file to make in executable run this in project directory — <strong>chmod +x .scripts/deploy.sh</strong></blockquote><p>Now your deployment process should become automatic using actions, to test it out, make some changes on your project locally and push to , GitHub it will trigger the workflow and execute the script, which will make the build available on the server, Just in case if you get any permission error on server you can make changes according to situation and we are all set !</p><p>I hope this story adds some value to your new or existing application, I attempted to convey the basic notion. Thanks for reading this story If you find any mistakes please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, you can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb36c8f08b13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install PHP 8.2 on AlmaLinux 9 | VPS]]></title>
            <link>https://ritik065.medium.com/install-php-8-2-on-almalinux-9-vps-bed204535ab1?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/bed204535ab1</guid>
            <category><![CDATA[vps]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Mon, 24 Feb 2025 07:35:30 GMT</pubDate>
            <atom:updated>2025-02-24T07:35:30.239Z</atom:updated>
            <content:encoded><![CDATA[<h4>We will install and use PHP 8.2 on our VPS or panel-managed server to deploy our laravel apps which need a specific version on the server.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZQZycLzbhESIpQCM" /><figcaption>Photo by <a href="https://unsplash.com/@6heinz3r?utm_source=medium&amp;utm_medium=referral">Gabriel Heinzer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Web servers running Linux, Windows, BSD, and macOS are among the operating systems that can execute and support PHP code. Additionally, it is supported by a sizable and vibrant community that actively contributes to creating helpful frameworks, libraries, and tools that enable PHP to reach thousands of developers.</p><p>PHP 7.4 has been retired and PHP 8.2 has been formally published. This version may be installed using the Remi PHP repository, however, AlmaLinux does not support it in EL9 or EL8. The subsequent guide will teach you how to install PHP 8.2 on AlmaLinux 9 or AlmaLinux 8 and import the REMI PHP Module. It will also provide some pointers on using the command line terminal to configure Nginx with FPM.</p><p>So let’s get started and get into our server terminal and locate the project directory, then the first thing we do is update existing packages.</p><pre>sudo dnf upgrade --refresh</pre><p>After this step, we need to Install EPEL,</p><blockquote><strong>What Is EPEL?</strong></blockquote><blockquote>EPEL (<strong>Extra Packages for Enterprise Linux</strong>) is a repository maintained by the Fedora Project that provides additional open-source software packages for <strong>RHEL (Red Hat Enterprise Linux), CentOS, AlmaLinux, and Rocky Linux</strong>. It includes high-quality, community-maintained packages that are not available in the default repositories.</blockquote><h4>PHP REMI Repository</h4><p>To install the Extra Packages for Enterprise Linux (EPEL) repository. The most popular software packages for Enterprise Linux are included in EPEL for users of AlmaLinux and related versions based on RHEL.</p><h4>REMI PHP Repo for AlmaLinux 9 (EL9)</h4><p>To install <strong>EPEL</strong> use the following <strong>(dnf)</strong> terminal command and after adding this command, make sure you enable the EPEL repository by the command given below after installation.</p><pre>sudo dnf install \<br><br>    https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \<br><br>    https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm</pre><pre>sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm -y</pre><blockquote><strong>What Is DNF?</strong></blockquote><blockquote><strong>DNF (Dandified Yum)</strong> is the next-generation package manager for <strong>RHEL, CentOS, Fedora, AlmaLinux, and Rocky Linux</strong>. It replaces the older <strong>YUM (Yellowdog Updater, Modified)</strong> and offers better performance, dependency resolution, and resource management.</blockquote><p>Cool, now you have done great for almaLinux 9 but what if you want to do it for AlmaLinux 8, don’t worry just follow these steps,</p><p>This command changes the version numbers.</p><pre>sudo dnf install \<br><br>    https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \<br><br>    https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-8.noarch.rpm</pre><pre>sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm -y</pre><p>So far you have done the installation part on your server, now it’s time to verify the installation to do it Next, verify the installation.</p><pre>dnf repolist | grep remi</pre><p>and you will get something like or you can run a List all modules command</p><pre>dnf module list</pre><pre>//This is the Example output when you check for remi repo on your server.<br><br>remi-modular     Remi&#39;s Modular repository for Enterprise Linux 9 - x86_64<br><br>remi-safe        Safe Remi&#39;s RPM repository for Enterprise Linux 9 - x86_64</pre><p>After the successful installation of the REMI repo let’s move to the PHP part and enable it on our server, to list all the available modules run this</p><pre>dnf module list php</pre><p>Next, enable PHP 8.2 with the following command.</p><pre>sudo dnf module enable php:remi-8.2 -y</pre><p>you can install PHP with the following command.</p><p><strong><em>Apache (httpd) Users:</em></strong></p><pre>sudo dnf install php -y</pre><p><strong><em>Nginx Users:</em></strong></p><pre>sudo dnf install php php-fpm -y</pre><p>Now, if are not using any Panel to manage your server and want to install any other packages manually on server You can do it too using the below dnf command</p><pre>sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-dom php-redis php-memcached php-memcache</pre><p>or you can search for your desired package using</p><pre>sudo dnf search php82-php-</pre><p>After installing PHP 8.2 and its extensions, use the following command to verify the version</p><pre>php -v</pre><h4>Conclusion</h4><p>In order to install the most recent version of PHP on your server for your CMS or development, this tutorial shows how to install PHP 8.2 on AlmaLinux EL 9 or EL 8 using the command line console and the Remi RPM repository.</p><p>I Hope this story adds some value in your new or existing Laravel application, I attempted to convey the basic notion. Thanks for reading this story if you find any mistake Please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, You can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bed204535ab1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Send Email: A Comprehensive Guide]]></title>
            <link>https://ritik065.medium.com/send-email-in-laravel-47ded3566260?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/47ded3566260</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Tue, 14 Jan 2025 11:58:17 GMT</pubDate>
            <atom:updated>2025-01-16T09:51:25.692Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Email communication plays a comprehensive role in today’s web applications. From sending notifications and password reset links to distributing newsletters, Laravel provides a complete guide to simplify the process. If you’re looking for an efficient way to manage emails, this Laravel Send Email guide will help you seamlessly integrate email functionality into your project.</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ujdjTqH75TlxjAw3" /><figcaption>Photo by <a href="https://unsplash.com/@maria_shalabaieva?utm_source=medium&amp;utm_medium=referral">Mariia Shalabaieva</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the realm of communication, the capacity to dispatch vital business updates, disseminate newsletters, or maintain connections with loved ones is of paramount importance. Laravel, a distinguished PHP framework, presents an elegant and powerful email management solution, seamlessly integrating various email-sending service providers to enhance your communication experience.</p><blockquote>This article will guide you through sending emails in Laravel, ranging from initial setup to more advanced functionalities.</blockquote><p>Email-sending service providers serve as an essential intermediary between your Laravel application and the email servers. By utilizing this service, you can concentrate on developing the core features of your application while entrusting the email delivery process to experienced professionals.</p><p>Additionally, these providers offer developers a dependable and user-friendly method to integrate email capabilities into their applications. While PHP-based websites typically utilize the Mail() function to send emails, this approach can often compromise security, as it is not the most secure method for sending and receiving emails on a website.</p><h4>Why Laravel to Send Emails?</h4><p>Laravel provides a number of utilities for setting up email on websites.</p><ul><li>Drivers include SMTP, Mailgun, SparkPost, Amazon SES, and Sendmail.</li><li>By removing the intricacies of email protocols and configurations, you can focus on the content and organization of your email.</li><li>Multiple mail drivers are supported out of the box, including SMTP, Sendmail, Amazon SES, and more.</li><li>Seamless interaction with Laravel’s built-in queueing system allows you to queue emails for background processing.</li><li>Laravel’s Mailable classes provide a structured way to define email-specific logic, making your code more organized and maintainable.</li><li>Localization Methods to set desired languages for specific users.</li></ul><h4>Prerequisites</h4><p>To begin utilizing email functionality, make sure you have a Laravel project established and operational. If you haven’t set one up yet, you can easily create it using Composer.</p><pre>composer global require laravel/installer</pre><ul><li>Laravel utilizes a configuration file named mail.php to establish email drivers and associated settings. To begin, access the config/mail.php file within your Laravel project.</li><li>Select the appropriate email driver by adjusting the driver option (for instance, SMTP, Mailgun, Sendmail, etc.).</li><li>Next, configure the settings specific to the selected driver. If you opt for the SMTP driver, ensure you provide the SMTP host, port, username, password, and other relevant details.</li><li>You will also need to create or modify your .env file located at the root of your Laravel project, setting the required environment variables for the mail driver you have chosen.</li></ul><pre>MAIL_MAILER=smtp<br>MAIL_HOST=smtp.gmail.com<br>MAIL_PORT=587<br>MAIL_USERNAME=your-username<br>MAIL_PASSWORD=your-password<br>MAIL_ENCRYPTION=tls</pre><ul><li>Finally, create or adjust email views in accordance with your needs within the resources/views/directory.</li><li>Generate a new Mailable class using the Artisan command:</li></ul><pre>php artisan make:mail sendMyEmail</pre><p>This command will generate a new file in app/Mail directory.</p><pre>?php<br><br>namespace App\Mail;<br><br>use Illuminate\Bus\Queueable;<br>use Illuminate\Contracts\Queue\ShouldQueue;<br>use Illuminate\Mail\Mailable;<br>use Illuminate\Mail\Mailables\Content;<br>use Illuminate\Mail\Mailables\Envelope;<br>use Illuminate\Queue\SerializesModels;<br><br>class sendMyEmail extends Mailable<br>{<br>    use Queueable, SerializesModels;<br>    public $mailData;<br>    /**<br>     * Create a new message instance.<br>     */<br>    public function __construct($mailData)<br>    {<br>        $this-&gt;mailData = $mailData;<br>    }<br><br>    /**<br>     * Get the message envelope.<br>     */<br>    public function envelope(): Envelope<br>    {<br>        return new Envelope(<br>            subject: &#39;Welcome Mail From My App&#39;,<br>        );<br>    }<br><br>    /**<br>     * Get the message content definition.<br>     */<br>    public function content(): Content<br>    {<br>        return new Content(<br>            view: &#39;emails.welcome&#39;,<br>        );<br>    }<br><br>    /**<br>     * Get the attachments for the message.<br>     *<br>     * @return array&lt;int, \Illuminate\Mail\Mailables\Attachment&gt;<br>     */<br>    public function attachments(): array<br>    {<br>        return [];<br>    }<br>}</pre><blockquote><em>Mailable in Laravel?</em></blockquote><blockquote>Mailable is a specialized class designed to represent an email message. It encapsulates the necessary logic and configuration for sending emails. Mailable classes facilitate the creation, customization, and dispatch of emails in a systematic and maintainable manner.</blockquote><blockquote>When you create a Mailable class, you can specify various elements of the email, including the recipient, subject line, and content. Additionally, Mailables enable the use of Laravel’s Blade templating engine, allowing for the creation of dynamic email views. Below is a general outline of how Mailables function within Laravel:</blockquote><blockquote><strong>Creating a Mailable: </strong>You can generate a new Mailable class using Laravel’s Artisan command-line tool. For instance, executing the following command will create a Mailable named WelcomeEmail: php artisan make:mail WelcomeEmail This command will produce a new WelcomeEmail class located in the app/Mail directory.</blockquote><blockquote><strong>Customizing the Mailable: </strong>Open the newly created WelcomeEmail class and modify the build method. This method is responsible for constructing the email message, allowing you to set the recipient, subject, and any additional data to be passed to the email view.</blockquote><blockquote><strong>Creating an Email View: </strong>Laravel expects email views to be found in the resources/views directory, with the default location being resources/views/mails. Create a Blade template file (e.g., welcome.blade.php) to outline the HTML structure and content of the email. You can access the data provided by the Mailable class within the email view.</blockquote><blockquote><strong>Sending the Email:</strong> To send the email, utilize the Mail facade or invoke the send method on the Mailable instance. For example, you can send the sendMyEmai lusing the following code:</blockquote><blockquote><em>use App\Mail\WelcomeEmail;<br>use Illuminate\Support\Facades\Mail;<br>Mail::to(&#39;example@example.com&#39;)-&gt;send(new sendMyEmail());</em></blockquote><blockquote>This code sends an instance of the sendMyEmail Mailable to the designated recipient. Mailable classes in Laravel offer a structured and reusable approach to managing email messages, simplifying the maintenance and management of your email functionalities. They provide a robust framework for handling email communications effectively.</blockquote><p>To proceed, develop a Blade view for your email within the resources/views/emails directory. For example, generate a welcome.blade.php file containing your HTML content. It will appear as follows.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br><br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;Welcome to Our Platform&lt;/title&gt;<br>    &lt;style&gt;<br>        body {<br>            font-family: Arial, sans-serif;<br>            margin: 0;<br>            padding: 0;<br>            background-color: #f9f9f9;<br>        }<br><br>        .container {<br>            max-width: 600px;<br>            margin: 30px auto;<br>            padding: 20px;<br>            background-color: #ffffff;<br>            border-radius: 8px;<br>            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);<br>        }<br><br>        .logo {<br>            text-align: center;<br>            margin-bottom: 20px;<br>        }<br><br>        .logo img {<br>            max-width: 150px;<br>        }<br><br>        .message {<br>            padding: 20px;<br>        }<br><br>        .message p {<br>            margin: 15px 0;<br>            color: #333333;<br>            line-height: 1.6;<br>        }<br><br>        .welcome {<br>            font-size: 18px;<br>            font-weight: bold;<br>            color: #4CAF50;<br>            margin-bottom: 20px;<br>        }<br><br>        .cta-button {<br>            display: inline-block;<br>            margin: 20px 0;<br>            padding: 10px 20px;<br>            background-color: #4CAF50;<br>            color: #ffffff;<br>            text-decoration: none;<br>            border-radius: 5px;<br>            font-size: 16px;<br>        }<br><br>        .footer {<br>            text-align: center;<br>            margin-top: 20px;<br>            font-size: 14px;<br>            color: #777777;<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br><br>&lt;body&gt;<br>    &lt;div class=&quot;container&quot;&gt;<br>        &lt;div class=&quot;logo&quot;&gt;<br>            &lt;img src=&quot;https://buymeacoffee.com/150&quot; alt=&quot;Company Logo&quot;&gt;<br>        &lt;/div&gt;<br><br>        &lt;div class=&quot;message&quot;&gt;<br>// remove this variable is you don&#39;t want to pass data.<br>            &lt;p class=&quot;welcome&quot;&gt;Welcome to Your Company Name, {{ $mailData[&#39;name&#39;] }}!&lt;/p&gt; <br>            &lt;p&gt;We’re thrilled to have you on board. Thank you for joining our platform. We&#39;re committed to providing you with the best experience possible.&lt;/p&gt;<br>            &lt;p&gt;If you have any questions or need assistance, feel free to reach out to our support team at &lt;a href=&quot;support@yourcompany.com&quot;&gt;support@yourcompany.com&lt;/a&gt;.&lt;/p&gt;<br>            &lt;p&gt;Click the button below to get started:&lt;/p&gt;<br>            &lt;a href=&quot;https://www.buymeacoffee.com/ritik065&quot; class=&quot;cta-button&quot;&gt;Get Started&lt;/a&gt;<br>        &lt;/div&gt;<br><br>        &lt;div class=&quot;footer&quot;&gt;<br>            &lt;p&gt;&amp;copy; 2025 Your Company Name. All rights reserved.&lt;/p&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/body&gt;<br><br>&lt;/html&gt;</pre><p>It is common to need to transfer data to your email template. This can be accomplished by incorporating public properties or constructor parameters into your email class. For example:</p><pre>Mail::to(&#39;demo@mail.com&#39;)-&gt;send(new sendMyEmail([<br>          &#39;name&#39; =&gt; &#39;Ritik&#39;,<br>     ]));</pre><h4>Conclusion</h4><p>Congratulations! You have completed the mail setup thing and I hope it’s working fine on your system too, I tried to break the process down into small parts to make it easy to understand for everybody. Enjoy creating and growing your apps!</p><p>I Hope this story adds some value in your new or existing Laravel application, I attempted to convey the basic notion. Thanks for reading this story if you find any mistake Please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, You can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47ded3566260" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Laravel on AWS EC2: A Comprehensive Guide]]></title>
            <link>https://ritik065.medium.com/deploy-laravel-on-aws-ec2-a-comprehensive-guide-b2830450da04?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2830450da04</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Fri, 10 Jan 2025 11:27:02 GMT</pubDate>
            <atom:updated>2025-01-10T11:27:02.796Z</atom:updated>
            <content:encoded><![CDATA[<h4>Ready to deploy the Laravel application</h4><h4>Assuming that you have a ready-to-deploy Laravel application, we will use an Ubuntu platform for our server and walk through the process of setting up an EC2 instance and database.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*joNEvxuTVNBWj_ud-jF6Vg.png" /></figure><p>New Laravel apps usually have some boilerplate code, which serves as a skeleton app from which to build. Because this lesson focuses on deployment, we will not modify this program. To have a quick peek, launch php artisan serve and visit <a href="http://localhost:8000/">http://localhost:8000</a> in your browser. <br> <br>We’ll send our application to AWS as a zipped file, so go to your project directory and compress all of the files and folders within one zipped file. You do not need to add your vendor folder because it is likely rather large and unnecessary for setup.</p><h4>Prerequisites</h4><p><strong>To complete this lesson, you will require the following:</strong></p><ul><li>An Amazon Web Services account</li><li>An EC2 instance running Amazon Linux 2 or any other suitable Linux distribution</li><li>A fundamental grasp of the Linux command line.</li><li>A Laravel application that is ready for deployment.</li></ul><p>Let’s Get <em>Started </em>Now!</p><h4>Step 1: Launch an EC2 instance.</h4><p>The first step is to launch an EC2 instance on AWS. Navigate to the AWS Management Console and choose EC2 from the list of services. Click “Launch Instance” and select an appropriate AMI (Amazon Machine Image) for your needs.</p><p>Now it&#39;s time to connect to your created instance You can connect to the Instance using the SSH command provided or an SSH client like PuTTY / FileZilla to log in:</p><pre>ssh -i your-key.pem ec2-user@your-public-ip</pre><p>Or, if you are facing any trouble using these, don’t worry connect using <strong>EC2 Instance Connect </strong>with username “ubuntu”.</p><blockquote><em>One more thing you want me to write a full guide on how to create and setup an EC2 instance, Please let me know by leaving a Comment.</em></blockquote><h4>Step 2: Prepare the Server</h4><p>To check the Ubuntu version on the server use this command</p><pre>lsb_release -a</pre><blockquote><strong><em>2.1 Update the System</em></strong></blockquote><p>Run the following commands to update your packages:</p><pre>sudo apt update &amp;&amp; sudo apt upgrade -y   # For Ubuntu</pre><blockquote><strong><em>2.2 Install Required Software</em></strong></blockquote><p>Install necessary software like PHP, Composer, and a web server.</p><p><strong><em>Install PHP and Extensions</em></strong></p><pre>sudo apt install php-cli php-fpm php-mysql php-xml php-mbstring php-curl unzip -y   # Ubuntu</pre><p><strong><em>Install Composer</em></strong></p><pre>sudo curl -sS https://getcomposer.org/installer | php<br>sudo mv composer.phar /usr/local/bin/composer</pre><p><strong><em>Install NGINX</em></strong></p><pre>sudo apt install nginx -y    # Ubuntu</pre><p>After Successfully Installing Ngnix on your server you can check it in <strong>etc directory </strong>using the command “cd etc” then “ls”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HdccvVuG-gmv2XlL" /></figure><p>Now To check if nginx is running or not.</p><pre>sudo systemctl status nginx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lek8GE8in_0FpVTl" /></figure><p>If everything we have done so far goes fine then you can see a welcome screen from ngnix when you will go on the public IP of your instance.</p><h4>Step 3: Time to Deploy Laravel Application</h4><blockquote><strong><em>3.1 Upload Your Laravel Code</em></strong></blockquote><ol><li>Use scp or an SFTP client like FileZilla to upload your Laravel application to the EC2 instance:</li></ol><pre>scp -i your-key.pem -r /path-to-your-laravel-project ec2-user@your-public-ip:/var/www/laravel-app</pre><p>2. Move your app to /var/www/:</p><pre>sudo mv ~/laravel-app /var/www/laravel-app</pre><p>You can also move your project here using Git for you need to install Git on your server using “sudo apt install git -y”</p><p>Next, clone your Laravel project into the EC2 instance. Assuming you have Git installed on your EC2 instance, run the following command to clone your Laravel project:</p><pre>git clone https://github.com/your_username/your_project.git /var/www/html</pre><p>This will clone your Laravel project into the /var/www/html directory.</p><blockquote>scp (Secure Copy Protocol) is a command-line tool that allows you to securely transfer files between a local machine and a remote server or between two remote servers. It uses SSH (Secure Shell) to provide encryption and security during the transfer.</blockquote><blockquote>Key Features:</blockquote><blockquote><strong>Security</strong>: Data is encrypted during transfer, ensuring privacy.</blockquote><blockquote><strong>Ease of Use</strong>: Works directly from the command line.</blockquote><blockquote><strong>Cross-Platform</strong>: Works on Linux, macOS, and Windows (with tools like PuTTY or OpenSSH).</blockquote><blockquote><strong><em>3.2 Set Permissions (</em></strong><em>Be </em>cautious <em>at this step</em><strong><em>)</em></strong></blockquote><p>Set proper ownership and permissions:</p><pre>sudo chown -R www-data:www-data /var/www/laravel-app<br>sudo chmod -R 775 /var/www/laravel-app/storage /</pre><p><em>if working to already set instances don’t run these commands on the server without proper knowledge of how things going on your server, Because changing ownership may cause issues on the server.</em></p><blockquote><strong><em>3.3 Install Dependencies</em></strong></blockquote><p>Navigate to the app directory and install dependencies:</p><pre>cd /var/www/laravel-app<br>composer install</pre><blockquote><strong><em>3.4 Set Up the </em></strong><strong><em>.env File</em></strong></blockquote><ol><li>Copy the example .env file:</li></ol><ul><li>cp .env.example .env</li></ul><p>2. Edit the .env file to configure your database and other settings:</p><ul><li>nano .env</li><li>Update DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD.</li></ul><p>3. Generate the application key:</p><ul><li>php artisan key:generate</li></ul><h4><strong>4: Configure NGINX</strong></h4><blockquote><strong><em>4.1 Create a Site Configuration</em></strong></blockquote><p>Create a new NGINX site configuration:</p><pre>sudo nano /etc/nginx/sites-available/laravel</pre><p>Add the following content:</p><pre>server {<br>    listen 80;<br>    server_name your-domain-or-ip;<br><br>    root /var/www/laravel-app/public;<br><br>    index index.php index.html index.htm;<br><br>    location / {<br>        try_files $uri $uri/ /index.php?$query_string;<br>    }<br><br>    location ~ \.php$ {<br>        include snippets/fastcgi-php.conf;<br>        fastcgi_pass unix:/var/run/php/php-fpm.sock;<br>        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br>        include fastcgi_params;<br>    }<br><br>    location ~ /\.ht {<br>        deny all;<br>    }<br>}</pre><blockquote><strong><em>4.2 Enable the Site</em></strong></blockquote><ol><li>Link the configuration:</li></ol><pre>sudo ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/</pre><p>2. Test the configuration:</p><pre>sudo nginx -t</pre><p>3. Restart NGINX:</p><pre>sudo systemctl restart nginx</pre><p>Till now we have done almost all the project-related setup and everything should be working fine including the server and dependencies, Let’s move to the Database part and get it all done.</p><h4>5: Set Up the Database</h4><ol><li>Install MySQL:</li></ol><pre>sudo apt install mysql-server -y   # Ubuntu</pre><p>2. Secure the installation:</p><pre>sudo mysql_secure_installation</pre><p>3. Create a database and user (and, To log in to SQL) :</p><p>You can do it using the below command:</p><pre>CREATE DATABASE laravel_app; CREATE USER &#39;laravel_user&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;your_password&#39;;<br>GRANT ALL PRIVILEGES ON laravel_app.* TO &#39;laravel_user&#39;@&#39;localhost&#39;; FLUSH PRIVILEGES;</pre><pre>sudo mysql -u root -p //to login into mysql</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W-2sKXhlN_rNpzMF" /></figure><h4>6: Finalize Laravel Configuration</h4><blockquote><strong><em>6.1 Run Migrations</em></strong></blockquote><p>Run Laravel migrations to set up the database:</p><pre>php artisan migrate</pre><blockquote><strong><em>6.2 Set Up Caching</em></strong></blockquote><p>Optimize Laravel for production:</p><pre>php artisan config:cache<br>php artisan route:cache<br>php artisan view:cache</pre><p>You should be now able to see your app running on an instance public IP address also you can now map your DNS with this to move further,</p><p>if you are willing to install SSL on this domain you can also so it using the command given below</p><pre>sudo apt install certbot python3-certbot-nginx -y<br>sudo certbot - nginx -d your-domain</pre><h3>Conclusion</h3><p>Congratulations! You successfully launched your Laravel application to AWS EC2. While it may appear difficult at first, breaking the process down into small parts makes it accessible to everybody. Enjoy creating and growing your cloud apps!</p><p>I Hope this story adds some value in your new or existing Laravel application, I attempted to convey the basic notion. Thanks for reading this story if you find any mistake Please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, You can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2830450da04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s AWS and Top Services]]></title>
            <link>https://ritik065.medium.com/whats-aws-and-top-services-754124be558c?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/754124be558c</guid>
            <category><![CDATA[services]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Fri, 20 Dec 2024 11:44:19 GMT</pubDate>
            <atom:updated>2024-12-20T11:44:19.170Z</atom:updated>
            <content:encoded><![CDATA[<h4>Say goodbye to server headaches — AWS lets you pay only for what you use, making cloud computing simpler and smarter</h4><h4>AWS (Amazon Web Services) is the largest cloud computing platform, including over 200 included resources. It is a platform that offers pay-as-you-go services. It’s no longer necessary to install servers and manage their upkeep and costs. AWS provides a “pay-as-you-go” feature in which you only pay for the services you utilize as well as the time period during which they are used.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*fWj1_gNew2zs0BxQJ1zajg.png" /></figure><p>This AWS Story is intended for those professionals who want to learn about Cloud Computing and will help you advance in your career as an AWS Solution Architect, AWS Engineer, DevOps Engineer, Cloud Architect, and so on. In this AWS Tutorial, we will first try to comprehend what is AWS and then move on to learn about its services.</p><p>In the years 2006–2007, businesses began developing services like computing and storage on their own private servers. However, as internet speeds have increased, businesses of all sizes are realizing the potential of the cloud and moving their data to the cloud to boost performance, freeing up resources for core competencies, and that’s how cloud computation became popular and useful,</p><blockquote>If you want to know more about basics of cloud computing you can absolutely go through my this given below article for better understanding.</blockquote><p><a href="https://ritik065.medium.com/introduction-to-cloud-computing-d31ac68b786d">Introduction to Cloud Computing.</a></p><p>It makes sense to learn about AWS Cloud services as every business has begun implementing cloud services in one form or another and AWS is a significant participant in the cloud services sector.</p><p><em>So now I assume at least you have basic idea of these terms if you are complete New to these thing, let’s get started then.</em></p><p>AWS services are quite stable to provide customer satisfaction. Amazon is regarded as a reliable advisor by all industry participants, ranging from tiny startups to large corporations, which is why AWS is a trusted provider.</p><p><strong>For Complete New Users :</strong></p><p><strong>AWS makes the sign-up procedure simple</strong>. You can go from 0 to 100 in only two minutes by simply signing up with your email address, adding a credit card, and that’s it. There’s no agreement involved. It only takes a few minutes to get your servers and large computers up and operating without the need to purchase any hardware. <br> <br><strong>They provide a pretty basic billing dashboard as well</strong>. You can get billing reports from their integrated billing dashboard. Reports on services and monthly reports can be retrieved using a variety of criteria.</p><h3>AWS Top and Most Used AWS Services</h3><p>AWS provides many offerings, in story we will be talking about most used and famous services offered by AWS that we might be using in our current or upcoming project commonly.</p><h4><strong>1. Amazon EC2 (Elastic Compute Cloud)</strong></h4><p>The quickest cloud computing service offered by AWS is Amazon EC2. For any workload, it provides scalable, dependable, secure, and virtual servers. This solution supports web-scale cloud computing and makes resource access simple for developers. This includes the greatest storage systems, networking infrastructure, and processors available. Developers are able to dynamically and swiftly scale capacity to meet business requirements. It offers more than 500 instances, and you can select the newest operating system, storage, networking, and CPU to suit your company’s requirements. Additionally, you just pay for what you use using Amazon EC2, and it scales with Amazon EC2 auto-scaling to have optimal storage and CPU configurations based on time.</p><p><strong><em>Use Cases:</em></strong></p><ul><li>Hosting websites and web applications</li><li>Running backend services and APIs</li><li>Development and testing environments</li></ul><h4>2. Amazon EBS (Elastic Block Store)</h4><p>The next service offered by AWS is Amazon EBS, a block storage solution made especially for Amazon EC2. Amazon EBS facilitates safe transaction management for workloads of any size. You are capable of managing a variety of workloads, including business, relational, and non-relational applications. Five distinct volume types are available for you to select from in order to maximize cost and effectiveness. Workloads for big data analytics engines like Hadoop and Spark can be resized with its assistance. Its lifecycle management develops guidelines for efficiently creating and maintaining backups. It is compatible with high-performance scaling workloads, including SAP and Microsoft technologies.</p><h4>3. Amazon RDS (Relational Database Services)</h4><p>Another service offered by AWS is Amazon RDS (Relational Database Service), which is a managed database for PostgreSQL, MariaDB, MySQL, and Oracle. You can create, manage, and scale databases in the cloud with Amazon RDS. By automating processes like database setup, hardware provisioning, patching, and backups, it offers great performance. By offering high availability, compatibility, and security for resources, it also aids in cost optimization. Additionally, it eliminates the need to install and maintain database software while it is in use. You can simply select any of the more than 15 engines available, including MySQL, PostgreSQL, Oracle, and others, based on your needs. It is a very accessible and safe AWS service.</p><h4>4. Amazon S3 (Simple Storage Service)</h4><p>Amazon has made it simple to store data anywhere, at any time. One of the greatest services offered by AWS is Amazon S3 (Simple Storage Service), an object storage solution with excellent performance, scalability, availability, and security. Additionally, you can retrieve data, which is kept in “storage classes” that allow for effective management and don’t require additional funding. For large enterprises that manage a lot of data for a variety of uses, Amazon S3 is the ideal solution. With its strong access restrictions, it can handle any amount of data, and its replication features guard against unintentional deletion and preserve data version controls.</p><h4>5. Amazon Lambda</h4><p>Amazon Lambda, a serverless, event-driven computing tool that enables you to run code for virtual apps or backend services automatically, is another intriguing offering from AWS. Working with solutions that use Amazon Lambda requires you to be concerned about servers and clusters. When you only pay for the services you use, it is also economical. All you need to do as a user is upload the code; Lambda will take care of the rest. Lambda offers broad availability and accurate software scaling. Code execution requests are handled appropriately by AWS Lambda, which processes hundreds to thousands of jobs per second. It is among the greatest services that AWS offers developers.</p><p><strong><em>Use Cases:</em></strong></p><ul><li>Event-driven application architectures (e.g., processing S3 events, DynamoDB streams)</li><li>Real-time data processing and analytics</li><li>Microservices and serverless API backends</li><li>Scheduled tasks and cron jobs</li></ul><h4>6. Amazon Auto-Scaling</h4><p>One of AWS’s greatest services is Amazon Auto-Scaling, which analyzes applications and modifies capacity to maintain consistent performance at the lowest feasible cost. Applications for numerous resources across services can be easily scaled up in a matter of seconds. It scales computing capability to suit business demands, and EC2 instances can be added or removed automatically to do this. There are two kinds of scaling: predictive (reaction based on forecasts) and dynamic (now changing demands). In addition to receiving the appropriate resource at the appropriate moment, it may be used in conjunction with Amazon EC2 Auto Scaling to dynamically scale your Amazon EC2 instances.</p><p>Examples of Use:</p><ul><li>Replace failed instances automatically to preserve the dependability and availability of the application.</li><li>Reduce expenses while satisfying performance standards by scaling resources up or down as necessary.</li><li>By planning capacity adjustments in advance, you can account for predicted traffic fluctuations.</li></ul><p>After all these Service one thing that is most important that you should really care about understanding <strong>AWS IAM (Identity and Access Management)</strong></p><p>AWS IAM is a centralized service for securely handling entry to AWS sources. It permits agencies to define and manipulate who can get admission to particular assets and what moves they could perform. IAM provides a granular level of manipulation over consumer permissions, roles, and rules, allowing corporations to adhere to the precept of least privilege. By managing identities and getting entry, IAM enhances the security posture of AWS environments and ensures that the best legal individuals or structures can interact with sources.</p><h4>AWS Pricing</h4><ul><li>AWS follows a pay per use model, meaning you only pay for what you use. For example, if you are using 10GB of space on S3 on AWS, you would be paying only for that 10GB, traditionally you have to buy an ‘x’ amount of storage say 20GB in advance, and even if you are using 10GB in the purchased space, you will be billed for the whole 20GB.</li><li>AWS offers a free use tier where you can use its services in a very basic way without paying anything. This allows you to start using AWS for free.</li></ul><h4>Conclusion</h4><p>the services we’ve discussed form the foundation of cloud computing and modern app development. AWS addresses a wide range of needs, offering scalable computing power with EC2 and fully managed databases through RDS. Core services like S3 for storage, VPC for security, and IAM for access management underscore AWS’s focus on delivering robust and secure cloud solutions. Meanwhile, innovative tools like Lambda and Autoscaling highlight the growing shift toward serverless and automated infrastructure, simplifying app deployment while optimizing costs. Together, these services empower businesses to innovate, adapt, and thrive in today’s rapidly evolving digital landscape.</p><p>I Hope this story adds some value in your new or existing Laravel application, I attempted to convey the basic notion. Thanks for reading this story if you find any mistake Please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, You can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=754124be558c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Cloud Computing.]]></title>
            <link>https://ritik065.medium.com/introduction-to-cloud-computing-d31ac68b786d?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/d31ac68b786d</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Wed, 11 Dec 2024 09:13:22 GMT</pubDate>
            <atom:updated>2024-12-11T09:13:22.901Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is Cloud Computing? A Comprehensive Guide for Aspiring Technologists</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JLr5qTvZLnzyHxBqXUouow.jpeg" /></figure><p>In the digital era, cloud computing has emerged as a cornerstone of modern technology. It powers countless applications, from streaming platforms like Netflix to collaborative tools like Google Docs. But what makes cloud computing such a transformative force in both personal and professional domains? This guide provides an in-depth look at the fundamentals of cloud computing, its practical applications, and its future impact.</p><h4>Defining Cloud Computing</h4><p>Cloud computing refers to the delivery of various computing services — including servers, storage, databases, networking, software, and analytics — via the internet, commonly known as “the cloud.” This model eliminates the need for owning and maintaining physical hardware, enabling users to access resources on demand from providers like Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP).</p><p>Think of it as a utility system, much like electricity. Instead of setting up your own power plant, you draw energy from a grid managed by a provider. Similarly, cloud computing allows you to utilize resources without the complexities of infrastructure management.</p><h4>Types of Cloud Computing</h4><p>Cloud computing solutions cater to diverse needs, generally falling into three categories:</p><p><strong>1. Public Cloud: </strong>Services are delivered over the internet and shared among multiple users. Examples include AWS, Azure, and Google Cloud.</p><p><strong>2. Private Cloud:</strong> Dedicated to a single organization, private clouds offer enhanced control and security but often require significant investment and maintenance.</p><p><strong>3. Hybrid Cloud: </strong>Combining public and private clouds, this model provides flexibility and security by leveraging the strengths of both.</p><h4>How Cloud Computing Functions</h4><p>The operational framework of cloud computing revolves around interconnected data centers managed by service providers. Here’s how it works:</p><p><strong>1. Infrastructure: </strong>Providers maintain vast data centers equipped with high-performance servers.<br><strong>2. Virtualization: </strong>Physical resources are divided into virtual machines that can be allocated to users as needed.<br><strong>3. Internet Access: </strong>Users interact with these resources through web browsers or dedicated applications, ensuring seamless connectivity.</p><h4>Advantages of Cloud Computing</h4><p><strong>1. Cost Efficiency:</strong><br> — Reduces capital expenditure on hardware.<br> — Pay-as-you-go pricing aligns costs with actual usage.</p><p><strong>2. Scalability:</strong><br> — Resources can be dynamically adjusted to meet workload demands, such as seasonal spikes in e-commerce traffic.</p><p><strong>3. Accessibility:</strong><br> — Enables access to applications and data from any location with an internet connection, fostering remote collaboration.</p><p><strong>4. Reliability:</strong><br> — Ensures high availability and robust disaster recovery mechanisms through redundant systems.</p><h4>Cloud Computing in Action</h4><p><strong>1. Netflix: </strong>Uses AWS to deliver content to millions of users worldwide, seamlessly handling fluctuating demand.</p><p><strong>2. Dropbox:</strong> Provides cloud-based storage solutions, enabling users to access files across multiple devices.</p><p><strong>3. Zoom:</strong> Relies on cloud infrastructure to support its video conferencing services, which have become indispensable for remote work.</p><h4>Addressing Security in Cloud Computing</h4><p>Security is a critical consideration for cloud adoption. Leading providers implement advanced measures such as encryption, firewalls, and regular compliance audits. Nonetheless, users must adopt best practices, including:</p><p><em>- Creating strong passwords and enabling multi-factor authentication.<br>- Regularly updating software to mitigate vulnerabilities.<br>- Ensuring adherence to regulatory standards for data protection.</em></p><h4>The Evolving Landscape of Cloud Computing</h4><p>Cloud technology continues to shape the future of IT through innovations in:</p><p><strong>Multi-Cloud Strategies: </strong>Organizations increasingly utilize multiple providers to diversify risk and enhance operational flexibility.<br><strong>Edge Computing:</strong> Shifts data processing closer to the source, reducing latency and enhancing performance.<br><strong>Sustainable Practices:</strong> Promotes environmentally friendly data centers to minimize carbon footprints.</p><h4>Conclusion</h4><p>Cloud computing is not just a technological trend; it’s a paradigm shift redefining how we store, manage, and access data. For students and professionals in tech fields, understanding the cloud’s potential is essential for navigating today’s digital ecosystem.</p><p>This article provides a foundation for exploring advanced topics, from in-depth provider comparisons to real-world implementation strategies. What aspects of cloud computing intrigue you most? Let’s continue the conversation in the comments and deepen our understanding of this transformative technology.</p><blockquote>Have you explored cloud technologies in your academic or professional projects? Share your insights and experiences below!</blockquote><p>I Hope this story adds some value in your new or existing Laravel application, I attempted to convey the basic notion. Thanks for reading this story if you find any mistake Please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, You can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d31ac68b786d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Events and Listeners]]></title>
            <link>https://ritik065.medium.com/laravel-events-and-listeners-4f8594011824?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f8594011824</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[events]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Sat, 16 Nov 2024 19:00:06 GMT</pubDate>
            <atom:updated>2024-11-16T19:00:06.777Z</atom:updated>
            <content:encoded><![CDATA[<h4>An event is an activity performed within the program, and the listener is the operation that replies to the event.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*2W6bYrKlrlCI6fTGWgZdLg.png" /></figure><p>Laravel provides a straightforward method for events and listeners, allowing you to simply subscribe or listen to any event in your application. You can register events with their listeners and specify what you want them to do upon a specific action. For example, when a new order is created, we would like to send an email or SMS to the seller. To summarize, an event is an activity performed in the program, and a listener is the operation that replies to the event.</p><h4>Let’s try to understand these separately for now</h4><p><strong>What is An Event?</strong></p><p>Events are how we connect to the actions of our application; they are only a means of observing an activity. For example, we may design a class to track the login activity, and the event class can perform certain actions when a user logs in.</p><p><strong>What is A Listener?</strong></p><p>A listener in Laravel is a class that listens for a specific event and performs actions in response to that event.</p><p>Listeners observe (listen) for events in your application, as the name implies. They can only, however, listen for particular events; each listener needs to be assigned to an event beforehand.</p><blockquote>Events and listeners are a great tool for decoupling web applications since they allow one event to have multiple separate listeners.</blockquote><h4>Now Let’s start with creating event and listener for our app</h4><p><strong>Creating an Event</strong></p><p>In Laravel, an event is a straightforward class that symbolizes a certain event that occurred within your application. Events can be used to alert other areas of your application to events or to start actions.</p><p>Run the following command:</p><pre>php artisan make:event TestingEvent</pre><p>This creates a new event class in app/Events/TestingEvent.php. Update it with the following content:</p><pre>&lt;?php<br>namespace App\Events;<br><br>use App\Models\TestModel; #change model accordingly<br>use Illuminate\Broadcasting\Channel;<br>use Illuminate\Broadcasting\InteractsWithSockets;<br>use Illuminate\Broadcasting\PresenceChannel;<br>use Illuminate\Broadcasting\PrivateChannel;<br>use Illuminate\Contracts\Broadcasting\ShouldBroadcast;<br>use Illuminate\Foundation\Events\Dispatchable;<br>use Illuminate\Queue\SerializesModels;<br><br>class TestingEvent{   <br>use Dispatchable, InteractsWithSockets, SerializesModels;<br><br>public $order;    <br>public function __construct(Order $order)<br>    {       <br>         $this-&gt;order = $order;    <br>    }<br>}</pre><p>This event will carry the Order model instance, allowing listeners to access the order details. In a real application, you would perform additional actions, such as sending an email or updating other records in the database, when this event is triggered.</p><h3>Creating a Listener</h3><p>A listener in Laravel is a class that listens for a specific event and performs actions in response to that event.</p><p>Now that we have an event, let’s create a listener that will respond to this event.</p><p>Run the following command to create a new listener:</p><pre>php artisan make:listener SendEventAction --event=TestingEvent</pre><p>after that on <em>app/Listeners/SendEventAction.php</em> file:</p><blockquote>In this case, our listener implements the <strong>ShouldQueue </strong>interface, which means that Laravel’s queue system will handle it. This improves performance when working on time-consuming activities. <br> <br>The listener would be executed synchronously if the <strong>ShouldQueue </strong>interface wasn’t implemented. This could cause your application to respond more slowly, but it might be helpful in some situations where you need to carry out activities synchronously rather than asynchronously.</blockquote><pre>&lt;?php<br>namespace App\Listeners;<br>use App\Events\TestingEvent;<br>use Illuminate\Contracts\Queue\ShouldQueue;<br>use Illuminate\Queue\InteractsWithQueue;<br>use Illuminate\Support\Facades\Log;<br><br>class SendEventAction implements ShouldQueue<br>{<br>    use InteractsWithQueue;<br>    public function handle(TestingEvent $event)<br>    {<br>        // send an email here<br>        Log::info(&#39;Hello from Listener&#39;);<br>        <br>    }<br>}</pre><h3>Registering the Event and Listener</h3><p>Events and listeners are automatically discovered by Laravel 11.x and later versions, eliminating the need for human registration. You can register your events and listeners in the EventServiceProvider</p><p>if you’re running an older version of Laravel.</p><p>The app/Providers directory contains the EventServiceProvider.php file. It enables you to centrally register the event listeners for your application. The listen-to property lists all listeners (values) and events (keys) in an array. The event service provider’s $listen array should be updated as follows:</p><pre>protected $listen = [<br>    Registered::class =&gt; [<br>        SendEmailVerificationNotification::class,<br>    ],<br>    TestingEvent::class =&gt; [<br>        Listener1::class,<br>        Listener2::class<br>    ]<br>];</pre><h3>Set up the controller</h3><p>The controller defines all other follow-up actions and contains all the logic that allows people to sign up for the newsletter. The Artisan command to build a new controller is as follows:</p><pre>php artisan make:controller EventTestController</pre><pre>&lt;?php<br>namespace App\Http\Controllers;<br>use App\Models\Order;<br>use App\Events\OrderPlaced;<br>use Illuminate\Http\Request;<br><br>class EventTestController extends Controller<br>{<br>    public function store(Request $request)<br>    {<br>        //some logic here <br><br>        event(new TestingEvent(&quot;hi&quot;));<br>        return response()-&gt;json([&#39;message&#39; =&gt; &#39;Hello&#39;);<br>    }<br>}</pre><p>after all this it’s time to setup your route for this function in this controller and that’s all you need to know how to setup Laravel Events and Listeners in your application.</p><p>I Hope this story adds some value in your new or existing Laravel application, I attempted to convey the basic notion. Thanks for reading this story if you find any mistake Please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, You can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f8594011824" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FastAPI : An Introduction to Using FastAPI]]></title>
            <link>https://ritik065.medium.com/fastapi-an-introduction-to-using-fastapi-1df91abc67b1?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/1df91abc67b1</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Sat, 14 Sep 2024 19:02:04 GMT</pubDate>
            <atom:updated>2024-09-14T19:02:04.637Z</atom:updated>
            <content:encoded><![CDATA[<h3>FastAPI : An Introduction to Using FastAPI</h3><h4>Understand the FastAPI framework and learn how to utilize it to write Python APIs.</h4><p>APIs function as messengers between various software programs, facilitating data exchange and collaboration to deliver the services and information we require in today’s digital environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zvP6gm-XexoJksrtftnoAw.jpeg" /></figure><p><strong>Let’s Start from start</strong></p><h3><strong>What is an API?</strong></h3><p>Application Programming Interface is referred to as API. A software bridge known as an API makes it possible for two apps to communicate with one another. An application on your phone connects to the Internet and sends data to a server when you use it. The server then processes the data and sends it back to your phone. The application on your phone then interprets the data and presents it to you in a readable way.</p><p>An API accepts requests from applications and sends them to servers. The server then processes the request and returns the data to the application. The application then understands and displays the data to the user.</p><blockquote>if you want to know more about API in detail, you can check this</blockquote><p><a href="https://ritik065.medium.com/what-is-an-api-seamless-integration-and-innovation-1af0b88254a9">What is an API | Seamless Integration and Innovation</a></p><h3>What is FastAPI</h3><p>FastAPI is a Python web framework for creating APIs (Application Programming Interfaces) quickly and easily. It includes a set of tools and capabilities that make it easy to build web apps that can receive and distribute data over the internet.</p><p>FastAPI is a cutting-edge Python web system designed to make it easier to create superior execution APIs. It was created by Sebastián Ramrez and has gained popularity due to its speed, type hinting support, automatic documentation creation, and asynchronous features. FastAPI is a powerful tool for designing dependable APIs with less code since it makes advantage of Python 3.7+ features like type annotations.</p><p>FastAPI is a modern, web framework for seamlessly designing APIs with Python 3.7+. <strong>Its key features comprise</strong>:</p><ul><li>Automatic generation of OpenAPI and JSON Schema documentation</li><li>Built-in OAuth2 and API key security</li><li>Dependency injection system</li><li>Interactive API exploration with Swagger UI</li><li>Automatic route handling</li><li>Asynchronous support using Python’s asyncio</li></ul><p>FastAPI’s great performance is noteworthy, as it is built on Starlette and Pydantic. In a nutshell, they are essential components that improve the functionality of FastAPI. FastAPI’s underlying web functionality is powered by Starlette, an asynchronous web framework. Whereas Pydantic is a data validation package used for data validation and parsing. This combination allows for quick development while maintaining peak performance.</p><p>FastAPI’s great performance is noteworthy, as it is built on Starlette and Pydantic. In a nutshell, they are essential components that improve the functionality of FastAPI. FastAPI’s underlying web functionality is powered by Starlette, an asynchronous web framework. Whereas Pydantic is a data validation package used for data validation and parsing. This combination allows for quick development while maintaining peak performance. FastAPI creates documentation for your API depending on the code you write. This documentation explains how other developers can use your API and what data it wants. It’s similar to having a handbook for your API without having to write it yourself.</p><h3>Installing FastAPI</h3><p>Python 3.7+ is required for FastAPI. Pip can be used to install it. Installing the ASGI server `uvicorn} and FastAPI are required.</p><pre>``<br># install fastapi<br><br>pip install fastapi<br><br><br># install uvicorn<br>pip install uvicorn<br></pre><p>Then Open VS code or Pycharm and save this code in a file and save in directory</p><pre>from fastapi import FastAPI <br>app = FastAPI()<br><br><br>@app.get(&quot;/&quot;) <br>def root(): <br>return {&quot;message&quot;: &quot;Hello World from FastAPI&quot;}</pre><p>Go to command prompt and navigate to the directory and hit this command</p><p><strong>uvicorn main:app — reload</strong></p><blockquote>`main` is the name of the Python file, and `app` is the variable that stores the FastAPI class. You can name them whatever you like.</blockquote><h3>Interactive API Docs</h3><p>Using the OpenAPI specification to define APIs, FastAPI creates a “schema” including all of your APIs. A definition or description of something is called a “schema”. Just an abstract description, not the code that makes it work. The two interactive documentation systems offered in FastAPI are powered by the OpenAPI schema.</p><p>You can also see the interactive API documentation (provided by <a href="https://github.com/swagger-api/swagger-ui">Swagger UI</a>): <a href="http://127.0.0.1:8000/docs">http://127.0.0.1:8000/docs</a></p><p>I hope you liked reading this article. I attempted to convey the basic notion.Thanks for reading this story if you find any mistake Please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, You can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1df91abc67b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel-PDF Using DomPDF]]></title>
            <link>https://ritik065.medium.com/laravel-pdf-using-dompdf-0bd1edafeb6e?source=rss-711e7b438292------2</link>
            <guid isPermaLink="false">https://medium.com/p/0bd1edafeb6e</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Ritik]]></dc:creator>
            <pubDate>Thu, 25 Jul 2024 10:55:12 GMT</pubDate>
            <atom:updated>2024-07-25T10:55:12.037Z</atom:updated>
            <content:encoded><![CDATA[<h4>Generating PDF files in Laravel projects</h4><p>In this story we will be generating Pdf using Laravel app with the help of famous package <strong>barryvdh/laravel-dompdf </strong>using simple steps so let’s get in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLX9zeFrZSOW5lI2VzQeNw.jpeg" /></figure><p>To generate PDF, we will use a <a href="https://github.com/barryvdh/laravel-dompdf">barryvdh/laravel-dompdf</a> package, which is just a Laravel wrapper for <a href="https://github.com/dompdf/dompdf">dompdf/dompdf</a> package.</p><p><strong>To use this package in our project, let’s install it with the help of composer</strong></p><pre>composer require barryvdh/laravel-dompdf</pre><p>Now add a route in <strong>routes/web.php</strong> file to call our controller</p><pre>&lt;?php<br>  <br>use Illuminate\Support\Facades\Route;<br>  <br>use App\Http\Controllers\PdfController;<br>  <br>Route::resource(&#39;users&#39;, PdfController::class);</pre><p>After this let’s see our controller, we can generate using two ways separately or combined it’s totally depends on our use, here i will be showing you both ways where you can use with blade file as HTML for pdf and with some data passed for the pdf to make it dynamic,</p><ol><li>Generate Pdf using blade file with <strong>PDF::loadView() </strong>method in our controller and download it</li></ol><p><em>This code assumes that the PDF design is in HTML format in the </em><em>resources/views/pdf.blade.php file.</em></p><pre>use Barryvdh\DomPDF\Facade\Pdf;<br> <br>public function download() {<br>    $pdf = Pdf::loadView(&#39;pdf&#39;);<br>    return $pdf-&gt;download();<br>}</pre><p>2. Now let’s see another way to generate by passing some data as array in pdf, this data can be changed accordingly that’s how it will generate dynamic pdf whenever requested.</p><pre>public function download() {<br>    $data = [<br>            &#39;name&#39; =&gt; &quot;ritik&quot;,<br>            &#39;email&#39; =&gt; &#39;ritik@test.com&#39;,<br>            &#39;phone&#39; =&gt; &#39;1234567890&#39;<br>    ];<br> <br>    $pdf = Pdf::loadView(&#39;pdf&#39;,$data);<br> <br>    return $pdf-&gt;download();<br>}</pre><p>After passing data into blade file we need to accept it to print it on PDF, for that we will create a<strong> pdf.blade.php</strong> file</p><p><strong>resources/views/pdf.blade.php</strong></p><pre>&lt;!doctype html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0&quot;&gt;<br>    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;ie=edge&quot;&gt;<br>    &lt;title&gt;pdf&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;table class=&quot;w-full&quot;&gt;<br>        &lt;tr&gt;<br>            &lt;td class=&quot;w-half&quot;&gt;<br>                &lt;img src=&quot;{{ asset(&#39;myimage.png&#39;) }}&quot; alt=&quot;image&quot; width=&quot;200&quot; /&gt;<br>            &lt;/td&gt;<br>            &lt;td class=&quot;w-half&quot;&gt;<br>                &lt;h2&gt;pdf ID: test523&lt;/h2&gt;<br>            &lt;/td&gt;<br>        &lt;/tr&gt;<br>    &lt;/table&gt;<br> <br>    &lt;div class=&quot;margin-top&quot;&gt;<br>        &lt;table class=&quot;details&quot;&gt;<br>            &lt;tr&gt;<br>                &lt;th&gt;Name&lt;/th&gt;<br>                &lt;th&gt;Email&lt;/th&gt;<br>                &lt;th&gt;Phone&lt;/th&gt;<br>            &lt;/tr&gt;<br>           &lt;tr&gt;<br>                &lt;td class=&quot;w-half&quot;&gt;<br>                    &lt;div&gt;&lt;h4&gt;To:&lt;/h4&gt;&lt;/div&gt;<br>                    &lt;div&gt;{{ $name }}&lt;/div&gt;<br>                    &lt;div&gt;{{ $email }}&lt;/div&gt;<br>                    &lt;div&gt;{{ $phone}}&lt;/div&gt;<br>                &lt;/td&gt;<br>            &lt;/tr&gt;<br>        &lt;/table&gt;<br>    &lt;/div&gt;<br> <br>    &lt;div class=&quot;footer margin-top&quot;&gt;<br>        &lt;div&gt;Thank you&lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Don’t forget to follow a clean Architecture to not create a messy project structure you can follow these steps to do it.</p><p><a href="https://ritik065.medium.com/a-perfect-laravel-architecture-69e9a008c56e">Laravel — A Clean Architecture</a></p><p><strong>To style our pdf</strong></p><ol><li>DomPDF only supports CSS 2.1 and a few CSS3 properties.</li><li>The CSS file for PDF is also placed in the /public directory</li><li>CSS file only loaded using the <a href="https://laravel.com/docs/helpers#method-asset">asset()</a> Laravel helper.</li></ol><p><em>To include your CSS file in pdf add this in your blade file</em></p><pre>    &lt;link rel=&quot;stylesheet&quot; href=&quot;{{ asset(&#39;pdf.css&#39;) }}&quot; type=&quot;text/css&quot;&gt;</pre><p>and then provide your desired CSS in this file to reflect it on PDF,</p><p>Now you must be thinking how to rename file as we want to make it more easier to recognize in explorer, i got you we can it too using simple method</p><pre>use Barryvdh\DomPDF\Facade\Pdf;<br> <br>public function download() {<br>    $fileName = &#39;test&#39;;<br>    $pdf = Pdf::loadView(&#39;pdf&#39;);<br> <br>    return $pdf-&gt;download($fileName. &#39;.pdf&#39;);<br>}</pre><p>if you want to open your pdf file directly on browser you can do it too using <strong>stream()</strong> method at the place of <strong>download()</strong></p><pre>// use this method to stream it download<br>return $pdf-&gt;download();<br><br>// use this method to stream it online <br>return $pdf-&gt;stream(); </pre><p><strong>Conclusion</strong></p><p>Give it a try, I hope it will make your pdf Generation process easier, Thanks for reading this story if you find any mistake Please let me know.</p><p><a href="https://www.buymeacoffee.com/ritik065"><em>If you find this Story Helpful, You can show some support to help me.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0bd1edafeb6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>