<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muneeb Ur Rehman</title>
    <description>The latest articles on DEV Community by Muneeb Ur Rehman (@muneebkh2).</description>
    <link>https://dev.to/muneebkh2</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F195050%2F18501db2-6da6-4801-8639-0e06520d34dc.jpg</url>
      <title>DEV Community: Muneeb Ur Rehman</title>
      <link>https://dev.to/muneebkh2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muneebkh2"/>
    <language>en</language>
    <item>
      <title>Laravel - Unlock the Power of Laravel Gates for Simplified Authorization</title>
      <dc:creator>Muneeb Ur Rehman</dc:creator>
      <pubDate>Sun, 14 Apr 2024 18:45:32 +0000</pubDate>
      <link>https://dev.to/muneebkh2/laravel-unlock-the-power-of-laravel-gates-for-simplified-authorization-514j</link>
      <guid>https://dev.to/muneebkh2/laravel-unlock-the-power-of-laravel-gates-for-simplified-authorization-514j</guid>
      <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;Are you searching for a robust solution to regulate access within your Laravel application? Look no further than Laravel Gates – your key to seamless authorization management. Gates offers a concise and expressive means to define access rules for various actions and resources within your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚙️ Understanding Gates&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Gates serve as PHP callables that assess defined authorization logic, returning either true or false. Leveraging Gates, you can safeguard routes, controller actions, or any other critical component of your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔑 Illustrative Example: Safeguarding User Features Access&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's consider a scenario where access to certain features is restricted to authenticated users. Here's how you can implement and utilize a Gate for this purpose:&lt;br&gt;
&lt;/p&gt;

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

use Illuminate\Support\Facades\Gate;

// Define a gate to grant access to certain features for regular users

Gate::define('access-user-features', function ($user) {
    return $user-&amp;gt;hasRole('user');
});

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

&lt;/div&gt;



&lt;p&gt;Subsequently, protect your route as follows:&lt;br&gt;
&lt;/p&gt;

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

// Protect the route to user features using the gate
Route::get('/user/features', function () {
    // Only allow access to users
})-&amp;gt;middleware('can:access-user-features');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🛡️ Harnessing Gates in Controllers:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Furthermore, Gates seamlessly integrates within controller methods, facilitating precise control over access to specific actions. For example, to exclusively permit authenticated users to update their profiles:&lt;br&gt;
&lt;/p&gt;

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

// Example usage of the gate in a controller method to update user profile
namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;

class UserController extends Controller
{
    public function update(Request $request, User $user)
    {
        // Check if the user is authorized to update their own profile
        if (Gate::denies('access-user-features')) {
            abort(403, 'Unauthorized action.');
        }

        // Logic for updating user profile
    }
}

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

&lt;/div&gt;



&lt;p&gt;With Laravel Gates, enforcing access control within your application becomes effortlessly manageable, ensuring heightened security and tranquility for both you and your users. 🔒✨&lt;/p&gt;

&lt;p&gt;Thank you and happy coding! 🖤&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Supercharging Laravel Development with Docker: A Comprehensive Guide</title>
      <dc:creator>Muneeb Ur Rehman</dc:creator>
      <pubDate>Fri, 26 May 2023 15:49:41 +0000</pubDate>
      <link>https://dev.to/muneebkh2/supercharging-laravel-development-with-docker-a-comprehensive-guide-1f1p</link>
      <guid>https://dev.to/muneebkh2/supercharging-laravel-development-with-docker-a-comprehensive-guide-1f1p</guid>
      <description>&lt;p&gt;In recent years, Docker has revolutionized the way developers build, ship, and deploy applications. Its lightweight, container-based approach has made it a popular choice for managing application dependencies and ensuring consistency across different environments. When combined with Laravel, one of the most powerful PHP frameworks, Docker becomes an invaluable tool for supercharging your Laravel development workflow. In this post, we'll explore advanced Docker techniques and demonstrate how they can enhance your Laravel development process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Dockerizing your Laravel Application:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first step in leveraging Docker for Laravel development is containerizing your application. We'll guide you through creating a Dockerfile that includes all the necessary dependencies, configurations, and environment variables required to run Laravel. By doing so, you'll be able to easily spin up your development environment on any machine without worrying about compatibility issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Optimizing Development with Docker Compose:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker Compose is a powerful tool that allows you to define and manage multi-container applications. We'll show you how to leverage Docker Compose to orchestrate your Laravel development stack, including services like a web server, database, and caching layer. With a single command, you can have a fully functional Laravel environment up and running, eliminating the need for manual setup and configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Isolating Laravel Dependencies with Docker Volumes:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Managing dependencies is a critical aspect of Laravel development. Docker volumes provide a convenient way to isolate your project dependencies from your host machine. We'll demonstrate how to use volumes to mount your Laravel application code and database files, ensuring that changes made within the container are persisted even when the container is restarted or rebuilt.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Scaling Laravel with Docker Swarm:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As your Laravel application grows, you may need to scale it to handle increased traffic and load. Docker Swarm, a native Docker clustering and orchestration tool, can help you achieve scalability and high availability. We'll discuss how to deploy your Laravel application using Docker Swarm, enabling you to distribute the workload across multiple containers and easily scale your application horizontally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Continuous Integration and Deployment with Docker:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In modern software development, CI/CD (Continuous Integration and Deployment) pipelines play a crucial role. Docker's portability makes it an ideal candidate for automating your CI/CD workflows. We'll explain how you can leverage Docker in combination with popular CI/CD tools like Jenkins, GitLab CI, or Travis CI to streamline your Laravel application's deployment process and ensure consistent builds across different environments.&lt;/p&gt;

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

&lt;p&gt;By incorporating Docker into your Laravel development workflow, you gain significant advantages in terms of portability, scalability, and consistency. The combination of these two powerful technologies empowers you to build robust and efficient Laravel applications. Whether you're a seasoned Laravel developer or just getting started, mastering Docker for Laravel development will undoubtedly boost your productivity and help you deliver high-quality software. So, why not take the leap and unlock the full potential of Laravel and Docker today?&lt;/p&gt;

&lt;p&gt;Remember, this post is just the tip of the iceberg when it comes to Docker and Laravel. Dive deeper into these topics, explore advanced techniques, and share your experiences with the community. Happy coding and happy blogging!&lt;/p&gt;

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

</description>
      <category>laravel</category>
      <category>docker</category>
      <category>php</category>
      <category>development</category>
    </item>
    <item>
      <title>Shopify App 🖇️ with laravel ✨</title>
      <dc:creator>Muneeb Ur Rehman</dc:creator>
      <pubDate>Wed, 18 Jan 2023 06:01:24 +0000</pubDate>
      <link>https://dev.to/muneebkh2/shopify-app-laravel-5bhk</link>
      <guid>https://dev.to/muneebkh2/shopify-app-laravel-5bhk</guid>
      <description>&lt;h2&gt;
  
  
  Install Laravel-Shopify Package
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;composer require osiset/laravel-shopify&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After installing above package run this command inside your project root directory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan vendor:publish --tag=shopify-config&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You're now able to access config in &lt;strong&gt;config/shopify-app.php&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;In your app's settings on your &lt;strong&gt;Shopify Partner&lt;/strong&gt; dashboard, you need to set the callback URL to be:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://(your-domain).com/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And the redirect_uri to be:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://(your-domain).com/authenticate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;callback&lt;/strong&gt; URL will point to the home route, while the &lt;strong&gt;redirect_uri&lt;/strong&gt; will point to the authentication route.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE:Those two URLs must start with https, otherwise you will get an error message: "Oauth error invalid_request: The redirect_uri is not whitelisted"&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h4&gt;
  
  
  Modify Env File
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SHOPIFY_APP_HOST_NAME="(you app host name)"
SHOPIFY_API_KEY="(your api key)"
SHOPIFY_API_SECRET="(your secret token)"
SHOPIFY_API_SCOPES="read_products,write_products,read_themes,write_themes,read_orders,read_customers"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  Modify Routing
&lt;/h4&gt;

&lt;p&gt;update &lt;strong&gt;routes/web.php&lt;/strong&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Route::get('/', function () {
    return view('welcome');
})-&amp;gt;middleware(['verify.shopify'])-&amp;gt;name('home');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, modify &lt;strong&gt;resources/views/welcome.blade.php&lt;/strong&gt; to extend this packages' layout for Shopify AppBridge abilities, example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@extends('shopify-app::layouts.default')

@section('content')
    &amp;lt;!-- You are: (shop domain name) --&amp;gt;
    &amp;lt;p&amp;gt;You are: {{ $shopDomain ?? Auth::user()-&amp;gt;name }}&amp;lt;/p&amp;gt;
@endsection

@section('scripts')
    @parent

    &amp;lt;script&amp;gt;
        actions.TitleBar.create(app, { title: 'Welcome' });
    &amp;lt;/script&amp;gt;
@endsection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>shopify</category>
      <category>laravel</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Laravel queues with supervisor - Docker Configuration</title>
      <dc:creator>Muneeb Ur Rehman</dc:creator>
      <pubDate>Thu, 26 May 2022 08:13:55 +0000</pubDate>
      <link>https://dev.to/muneebkh2/laravel-queues-with-supervisor-docker-configuration-l77</link>
      <guid>https://dev.to/muneebkh2/laravel-queues-with-supervisor-docker-configuration-l77</guid>
      <description>&lt;p&gt;I am writing this blog for those people who are facing difficulties for setting up the queues with supervisor using docker. &lt;/p&gt;

&lt;p&gt;So we'll going to create a separate service of docker for supervisor to do better performance.&lt;/p&gt;

&lt;p&gt;first we need to configure the main &lt;code&gt;docker-compose.yml&lt;/code&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;supervisor:
    build:
      context: .
      dockerfile: {path to file}/supervisor.dockerfile
    container_name: supervisor
    volumes:
      - ./src:/var/www/html
    networks:
      - laravel

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

&lt;/div&gt;



&lt;p&gt;then need to create a separate dockerfile for supervisor &lt;code&gt;supervisor.dockerfile&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM php:7.4-fpm-alpine // I'm using 7.4 you can use php-version as per your application.

RUN docker-php-ext-install pdo pdo_mysql

RUN apk update &amp;amp;&amp;amp; apk add --no-cache supervisor

RUN mkdir -p "/etc/supervisor/logs"

COPY {path to file}/supervisord.conf /etc/supervisor/supervisord.conf

CMD ["/usr/bin/supervisord", "-n", "-c",  "/etc/supervisor/supervisord.conf"]

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

&lt;/div&gt;



&lt;p&gt;after that we need to create a &lt;code&gt;supervisord.conf&lt;/code&gt; configuration file and set the logs directory and etc... in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[supervisord]
logfile=/etc/supervisor/logs/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=5MB         ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
loglevel=info                ; log level; default info; others: debug,warn,trace
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false               ; start in foreground if true; default false
minfds=1024                  ; min. avail startup file descriptors; default 1024
minprocs=200                 ; min. avail process descriptors;default 200

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/worker.log
stopwaitsecs=3600
stdout_logfile_maxbytes=5MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and that's it.&lt;/p&gt;

&lt;p&gt;now run &amp;amp; rebuild the docker container and it's worked like a boom 💥&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

&lt;p&gt;** If you have any question so you can ask in comment section &lt;/p&gt;

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