<?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: Al-Amin Islam</title>
    <description>The latest articles on DEV Community by Al-Amin Islam (@developeralamin).</description>
    <link>https://dev.to/developeralamin</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%2F619546%2F162ccac8-bff9-48c1-a476-b1ce1afc88aa.jpeg</url>
      <title>DEV Community: Al-Amin Islam</title>
      <link>https://dev.to/developeralamin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/developeralamin"/>
    <language>en</language>
    <item>
      <title>Software engineering</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Thu, 23 Jan 2025 17:42:12 +0000</pubDate>
      <link>https://dev.to/developeralamin/software-engineering-1l8c</link>
      <guid>https://dev.to/developeralamin/software-engineering-1l8c</guid>
      <description>&lt;p&gt;সফটওয়্যার ডেভেলপমেন্টে নতুন নতুন টেকনোলজি (React, Django, Flutter) আসবে-যাবে, কিন্তু কিছু মৌলিক বিষয় কখনও পুরোনো হবে না। সেগুলো ঠিকঠাক জানা থাকলে, আপনি একজন প্রকৃত সফটওয়্যার ইঞ্জিনিয়ার হিসেবে সবসময় সঠিকভাবে নিজেকে প্রস্তুত রাখতে পারবেন।&lt;/p&gt;

&lt;p&gt;👉 এই বিষয়গুলো সব ডেভেলপারেরই জানা উচিত:&lt;/p&gt;

&lt;p&gt;1️⃣ Data Structures and Algorithms&lt;br&gt;
কেন?&lt;br&gt;
সমস্যার সমাধানে কার্যকরী ও দক্ষ পদ্ধতি খুঁজে বের করতে DSA অপরিহার্য।&lt;br&gt;
টপিকস:&lt;br&gt;
    Arrays, Linked Lists, Stacks, Queues&lt;br&gt;
    Trees (Binary Tree, BST), Graphs&lt;br&gt;
    Hashing, Heaps, Tries&lt;br&gt;
    Sorting এবং Searching Algorithms (Quick Sort, Merge Sort, Binary Search)&lt;br&gt;
    Dynamic Programming, Greedy Algorithms&lt;br&gt;
কার্যকরী ক্ষেত্র:&lt;br&gt;
Performance optimization, code efficiency, এবং scalability&lt;/p&gt;

&lt;p&gt;2️⃣ Object-Oriented Programming (OOP)&lt;br&gt;
কেন?&lt;br&gt;
OOP-এর ধারণাগুলো বেশিরভাগ প্রোগ্রামিং ল্যাঙ্গুয়েজে ব্যবহার হয় (Java, Python, C++, etc.) এবং বড় বড় সফটওয়্যার তৈরির সময় OOP অপরিহার্য।&lt;br&gt;
টপিকস:&lt;br&gt;
    Abstraction, Encapsulation, Inheritance, Polymorphism&lt;br&gt;
    SOLID Principles&lt;br&gt;
    Design Patterns (Factory, Singleton, Observer, etc.)&lt;/p&gt;

&lt;p&gt;3️⃣ Design Patterns&lt;br&gt;
কেন?&lt;br&gt;
কোডের পুনর্ব্যবহারযোগ্যতা, মডুলারিটি, এবং maintainability বাড়াতে।&lt;br&gt;
টপিকস:&lt;br&gt;
    Creational Patterns (Factory, Builder)&lt;br&gt;
    Structural Patterns (Adapter, Composite)&lt;br&gt;
    Behavioral Patterns (Observer, Strategy)&lt;/p&gt;

&lt;p&gt;4️⃣ Software Architecture&lt;br&gt;
কেন?&lt;br&gt;
বড় সফটওয়্যার সিস্টেম তৈরির সময় সঠিক আর্কিটেকচার ডিজাইন না করলে স্কেলিং এবং পারফরম্যান্স সমস্যা হয়।&lt;br&gt;
টপিকস:&lt;br&gt;
    Monolithic vs Microservices&lt;br&gt;
    Client-Server Architecture&lt;br&gt;
    MVC, MVVM, Clean Architecture&lt;br&gt;
    Distributed Systems এবং Scalability&lt;/p&gt;

&lt;p&gt;5️⃣ Databases&lt;br&gt;
কেন?&lt;br&gt;
ডেটা ম্যানেজমেন্ট প্রতিটি সফটওয়্যার সিস্টেমের মেরুদণ্ড।&lt;br&gt;
টপিকস:&lt;br&gt;
    SQL এবং NoSQL Databases&lt;br&gt;
    Normalization এবং Indexing&lt;br&gt;
    Transactions এবং ACID Properties&lt;br&gt;
    Query Optimization&lt;br&gt;
    Caching Mechanisms (Redis, Memcached)&lt;/p&gt;

&lt;p&gt;6️⃣ Networking Basics&lt;br&gt;
কেন?&lt;br&gt;
ইন্টারনেটে বা ক্লাউডে কাজ করার সময় নেটওয়ার্কের ধারণা অপরিহার্য।&lt;br&gt;
টপিকস:&lt;br&gt;
    HTTP/HTTPS, FTP, WebSockets&lt;br&gt;
    REST এবং GraphQL APIs&lt;br&gt;
    DNS, IP, TCP/UDP&lt;br&gt;
    Load Balancing এবং CDN&lt;br&gt;
    Authentication Protocols (OAuth, JWT)&lt;/p&gt;

&lt;p&gt;7️⃣ Version Control (Git)&lt;br&gt;
কেন?&lt;br&gt;
টিমের সাথে কাজ করার সময় কোড ম্যানেজমেন্ট এবং ট্র্যাকিং করার জন্য অপরিহার্য।&lt;br&gt;
টপিকস:&lt;br&gt;
    Git Basics (Clone, Commit, Push, Pull)&lt;br&gt;
    Branching এবং Merging&lt;br&gt;
    Conflict Resolution&lt;br&gt;
    GitHub/GitLab&lt;/p&gt;

&lt;p&gt;8️⃣ Testing &amp;amp; Debugging&lt;br&gt;
কেন?&lt;br&gt;
বাগমুক্ত এবং reliable সফটওয়্যার নিশ্চিত করতে।&lt;br&gt;
টপিকস:&lt;br&gt;
    Unit Testing, Integration Testing&lt;br&gt;
    Debugging Techniques&lt;br&gt;
    Automation Testing Frameworks (Selenium, Cypress, etc.)&lt;/p&gt;

&lt;p&gt;9️⃣ Command Line &amp;amp; Shell Scripting&lt;br&gt;
কেন?&lt;br&gt;
ডেভেলপমেন্ট এবং ডিপ্লয়মেন্টের সময় কাজ দ্রুত করার জন্য।&lt;br&gt;
টপিকস:&lt;br&gt;
    Unix/Linux Commands&lt;br&gt;
    Bash Scripting&lt;br&gt;
    Automating Tasks&lt;/p&gt;

&lt;p&gt;🔟 Cloud এবং Deployment Basics&lt;br&gt;
কেন?&lt;br&gt;
সফটওয়্যার তৈরি করে সেটি প্রোডাকশনে তোলা এখনকার সময়ে অত্যন্ত গুরুত্বপূর্ণ।&lt;br&gt;
টপিকস:&lt;br&gt;
    Cloud Platforms (AWS, Azure, GCP)&lt;br&gt;
    Docker এবং Kubernetes&lt;br&gt;
    CI/CD Pipelines&lt;/p&gt;

&lt;p&gt;1️⃣1️⃣ Security Basics&lt;br&gt;
কেন?&lt;br&gt;
ব্যবহারকারীর ডেটা সুরক্ষিত রাখা এবং সিস্টেম হ্যাকিং থেকে রক্ষা করা।&lt;br&gt;
টপিকস:&lt;br&gt;
    Authentication এবং Authorization&lt;br&gt;
    OWASP Top 10&lt;br&gt;
    Encryption এবং Hashing&lt;br&gt;
    XSS, CSRF, SQL Injection প্রতিরোধ&lt;/p&gt;

&lt;p&gt;1️⃣2️⃣ Problem-Solving Skills&lt;br&gt;
কেন?&lt;br&gt;
সফটওয়্যার ডেভেলপমেন্ট মানে সমস্যা সমাধান করা। লজিক্যাল চিন্তাভাবনা এবং সমস্যাকে টুকরো টুকরো করে সমাধান করার ক্ষমতা থাকা দরকার।&lt;br&gt;
টপিকস:&lt;br&gt;
    Logical Thinking&lt;br&gt;
    Breaking down complex problems&lt;/p&gt;

&lt;p&gt;1️⃣3️⃣ Soft Skills&lt;br&gt;
কেন?&lt;br&gt;
সফটওয়্যার ডেভেলপমেন্টে টিমওয়ার্ক এবং কমিউনিকেশন খুবই গুরুত্বপূর্ণ।&lt;br&gt;
টপিকস:&lt;br&gt;
    Team Collaboration&lt;br&gt;
    Effective Communication&lt;br&gt;
    Time Management&lt;/p&gt;

&lt;p&gt;শেষ কথা:&lt;br&gt;
প্রকৃত সফটওয়্যার ইঞ্জিনিয়ার হওয়া মানে শুধুমাত্র একটি টুল বা ফ্রেমওয়ার্ক জানা নয়। বরং সমস্যার সমাধানের দক্ষতা এবং নতুন টেকনোলজি শেখার মানসিকতাই আপনাকে সফল করবে। 🌟&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Example of using Late Static Binding in PHP.</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Wed, 15 Jan 2025 17:31:34 +0000</pubDate>
      <link>https://dev.to/developeralamin/example-of-using-late-static-binding-in-php-18kh</link>
      <guid>https://dev.to/developeralamin/example-of-using-late-static-binding-in-php-18kh</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Late Static Binding (LSB) is a feature in PHP that allows a child class to reference its parent class's static properties or methods using the static keyword. This feature opens the door to dynamic behavior within your classes. It's especially useful when dealing with inheritance and customization of functionality in subclasses.&lt;br&gt;
The late static binding concept is used by writing static keyword before using the property. Whenever a PHP interpreter gets the request to compile a function. If it sees any static property, then it leaves the property pending for run time and the property gets its value during runtime from the function it is being called. This is called late static binding.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;
&lt;h2&gt;
  
  
  The Scenario:
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
Consider a scenario where you are developing a web application with a database. You have a base Database class that contains common functionality for interacting with the database, such as DBquerying and data retrieval. Additionally, you have two subclasses, User and Product, each representing a different entity in your application. These subclasses need to perform database queries specific to their respective tables.&lt;/p&gt;
&lt;h2&gt;
  
  
  Implementing Late Static Binding:
&lt;/h2&gt;

&lt;p&gt;Let's dive into the code to see how Late Static Binding can help us achieve dynamic database queries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt; 
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$tableName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getTableName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;return&lt;/span&gt;  &lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nv"&gt;$tableName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;dbQuery&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$tableName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nv"&gt;$tableName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"SELECT * FROM &lt;/span&gt;&lt;span class="nv"&gt;$tableName&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$tableName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"users"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Products&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nv"&gt;$tableName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"products"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;dbQuery&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;  &lt;span class="c1"&gt;//SELECT * FROM users;&lt;/span&gt;
&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Products&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;dbQuery&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;  &lt;span class="c1"&gt;//SELECT * FROM products;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation:
&lt;/h2&gt;

&lt;p&gt;In the Database class, we define a static property $tableName, which represents the name of the database table.&lt;/p&gt;

&lt;p&gt;The getTableName() method returns the table name using Late Static Binding with static::$tableName.&lt;/p&gt;

&lt;p&gt;The dbQuery() method constructs and returns a query string that includes the specific table name obtained using static::getTableName()&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;Late Static Binding in PHP is a powerful tool that allows developers to create flexible and dynamic systems. In the example provided, we demonstrated how to use Late Static Binding to implement dynamic database queries in a web application. This feature empowers subclasses to access their own static properties and methods while maintaining a clear and organized class hierarchy. Incorporating Late Static Binding in your PHP applications can greatly enhance their flexibility and maintainability, ultimately leading to more robust and adaptable codebases.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>php</category>
      <category>programming</category>
    </item>
    <item>
      <title>Understanding authentication and authorization in simple words</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Thu, 28 Nov 2024 04:18:14 +0000</pubDate>
      <link>https://dev.to/developeralamin/understanding-authentication-and-authorization-in-simple-words-1fm2</link>
      <guid>https://dev.to/developeralamin/understanding-authentication-and-authorization-in-simple-words-1fm2</guid>
      <description>&lt;p&gt;Suppose you want to enter a restricted area. You can't just enter there, you will definitely need a pass card to enter. Suppose it is an ID card, with this ID card you can enter all parts of that area except some VIP areas. This card has a validity period, which I will discuss later some day. Now the point is that as long as you have this valid ID card, you can access inside, whenever you lose the ID card or the validity period expires, you will be kicked out of that area . This is authentication&lt;/p&gt;

&lt;p&gt;Now let's tell you what authorization means. Above I was talking about VIP areas, which you cannot enter even if you have a pass. You will need special permission to enter. This is what authorization is&lt;/p&gt;

&lt;p&gt;Now let's see an example in programming:&lt;br&gt;
Suppose you want to enter an admin panel. You will need your credentials to enter there, login with them and create a post on this panel, this is authentication. Now you have created the post but you do not have permission to delete it, this is authorization.&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>softwareengineering</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is the process to Sign In with Apple with laravel?</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Wed, 11 Sep 2024 00:33:03 +0000</pubDate>
      <link>https://dev.to/developeralamin/what-is-the-process-to-sign-in-with-apple-with-laravel-34nd</link>
      <guid>https://dev.to/developeralamin/what-is-the-process-to-sign-in-with-apple-with-laravel-34nd</guid>
      <description>&lt;p&gt;The Sign In with Apple Flow . How Sign In with Apple Works (Hint: it uses OAuth and OIDC) . &lt;br&gt;
Today I will try to show how to login with apple. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No.1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mandatory Check this url If you click on this URL, you can see how to create Apple's service&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://developer.okta.com/blog/2019/06/04/what-the-heck-is-sign-in-with-apple" rel="noopener noreferrer"&gt;Create Apple Service on Apple developer Account&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No.2&lt;/strong&gt;&lt;br&gt;
You need to install laravel socialite package on your project&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then you will need to  install apple socialiteproviders . Check this url &lt;a href="https://dev.tocomposer%20require%20socialiteproviders/apple"&gt;Apple SocialiteProviders&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You need some configuration on your laravel projects &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;config/services.php&lt;br&gt;
 thats have provide . &lt;a href="https://dev.tocomposer%20require%20socialiteproviders/apple"&gt;Apple SocialiteProviders&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; &lt;br&gt;
If it doesn't work you just need to add some others field which will get you from apple service developer account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'apple' =&amp;gt; [
    'client_id' =&amp;gt; env('APPLE_CLIENT_ID'),
    'client_secret' =&amp;gt; env('APPLE_CLIENT_SECRET'),
    'team_id' =&amp;gt; env('APPLE_TEAM_ID'),
    'key_id' =&amp;gt; env('APPLE_KEY_ID'),
    'private_key' =&amp;gt; str_replace('\\n', "\n", env('APPLE_PRIVATE_KEY')),
    'redirect' =&amp;gt; env('APPLE_REDIRECT_URL'),
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;your laravel .env file looks like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;APPLE_CLIENT_ID='xxxxxxxxx'
APPLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n token \n-----END PRIVATE KEY-----"

APPLE_TEAM_ID="xxxxxx"
APPLE_KEY_ID="xxxxxxxx"
APPLE_CLIENT_SECRET="xxxxxxxxxx"

APPLE_REDIRECT_URL="http://127.0.0.1:8000/auth/login/apple/callback"
APPLE_REDIRECT_URI="http://127.0.0.1:8000/auth/login/apple/callback"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;No. 3&lt;/strong&gt;&lt;br&gt;
Now you need to create a Apple secret which is very important for Apple login. For creating Apple secret you can following this website . &lt;a href="https://bannister.me/blog/generating-a-client-secret-for-sign-in-with-apple-on-each-request" rel="noopener noreferrer"&gt;Generate Apple token&lt;/a&gt; .  For generate JWT token you will need to install this package .&lt;br&gt;
&lt;code&gt;composer require lcobucci/jwt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now you are ready for creating route in socialite login.&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('login/apple',[SocialController::class,'redirectToProvider'])-&amp;gt;name('redirectToProvider');
Route::post('login/apple/callback',[SocialController::class,'handleProviderCallback'])-&amp;gt;name('handleProviderCallback');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the controller&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

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Laravel\Socialite\Facades\Socialite;
use App\Models\User;
use Illuminate\Support\Facades\Log;


class SocialController extends Controller
{
  public function redirectToProvider()
  {
    Log::info("apple");
    return Socialite::driver('apple')-&amp;gt;redirect();
  }

public function handleProviderCallback()
{
    try {
        $user = Socialite::driver('apple')-&amp;gt;stateless()-&amp;gt;user();
    } catch (\Exception $e) {
        return redirect()-&amp;gt;route('login')-&amp;gt;with('error', 'Failed to log in with Apple.');
    }

    $provider_id = $user-&amp;gt;getId();
    $email = $user-&amp;gt;getEmail() ?? 'no-email-provided';

    $existingUser = User::where('provider_id', $provider_id)-&amp;gt;orWhere('email', $email)-&amp;gt;first();

    if ($existingUser) {
        auth()-&amp;gt;login($existingUser);
    } else {
        $newUser = User::create([
            'name' =&amp;gt; $user-&amp;gt;getName() ?? 'Apple User',
            'email' =&amp;gt; $email,
            'provider_id' =&amp;gt; $provider_id,
            'provider_name' =&amp;gt; 'apple'
        ]);

        auth()-&amp;gt;login($newUser);
    }

    // If it's a mobile app, generate and redirect with a token
    $token = auth()-&amp;gt;user()-&amp;gt;createToken('authToken')-&amp;gt;accessToken;

    return $token;
 }

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

&lt;/div&gt;



&lt;p&gt;I hope this will works . If you can face any problem on it feel free to knock me &lt;a href="//alamincsetpi@gmail.com"&gt;Email&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alamincsetpi@gmail.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or you can comment in this below.&lt;/p&gt;

&lt;p&gt;Thanks🤪&lt;br&gt;
Happy coding❤️🤪&lt;/p&gt;

</description>
      <category>socialitelogin</category>
      <category>laravel</category>
      <category>socialiteproviders</category>
      <category>swift</category>
    </item>
    <item>
      <title>Why you should never use $request-&gt;all() in Laravel</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Wed, 04 Sep 2024 10:31:13 +0000</pubDate>
      <link>https://dev.to/developeralamin/why-you-should-never-use-request-all-in-laravel-3k59</link>
      <guid>https://dev.to/developeralamin/why-you-should-never-use-request-all-in-laravel-3k59</guid>
      <description>&lt;p&gt;I know a lot of Laravel developer makes use of $request-&amp;gt;all()when making a POST request in Laravel.&lt;/p&gt;

&lt;p&gt;So I did this website for a client and it has been live for some time, then suddenly the website became popular and hackers came to attack it, for weeks I kept fighting all forms of attack, what baffled me most is that the hacker keeps giving himself an admin account! yes, you read that right, he keeps granting himself an admin account.&lt;/p&gt;

&lt;p&gt;I didn't know how he kept doing this, not until I went to the basics and started reading on all function by Laravel, then I read about $request-&amp;gt;all(). NOw here is why you should never use request all especially when it comes to user registration part.&lt;/p&gt;

&lt;p&gt;Now imagine a User Model with this fillable &lt;code&gt;protected $fillable = [‘username’,’first_name’, ‘last_name’, ‘password’, ‘email’, ‘team_id’, ‘country’, ‘status’, ‘IsAdmin’,’avatar’];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and probably in your controller, you have something like&lt;/p&gt;



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

{

$rules = [

‘username’ =&amp;gt; [‘required’, ‘string’, ‘max:255’,’unique:users’],

‘first_name’ =&amp;gt; [‘required’, ‘string’, ‘max:255’,],

‘last_name’ =&amp;gt; [‘required’, ‘string’, ‘max:255’,],

‘email’ =&amp;gt; [‘required’, ‘string’, ‘max:500’, ‘unique:users’],

‘password’ =&amp;gt; [‘required’, ‘string’, ‘min:8’, ‘confirmed’],

‘country’ =&amp;gt; [‘required’, ‘integer’],

];

$credentials = $request-&amp;gt;all();

$validator = Validator::make($credentials, $rules);

if ($validator-&amp;gt;fails()) {

return response()-&amp;gt;json([‘errors’ =&amp;gt; $validator-&amp;gt;errors()], 422);

}

$data = $request-&amp;gt;all(); // dont ever do this..NEVER!!!!

try {

DB::beginTransaction();

$user = User::create($data);

$token = JWTAuth::fromUser($user);

// Mail::to($user)-&amp;gt;send(new NewUserEmail($user));

DB::commit();

return response()-&amp;gt;json(array_merge([‘token’ =&amp;gt; $token, ‘message’ =&amp;gt; ‘Account created successfully’]), 201);

} catch (\Exception $e) {

DB::rollback();

return response()-&amp;gt;json([‘code’ =&amp;gt; 422,’message’ =&amp;gt; ‘Sorry an Error occured’], 422);

}

}
`Now the issue here is that the hacker can just inspect elements in your browser and add another input field of IsAdmin and send it, of course, it will be accepted because you are accepting all requests.

Rather than accepting all, here is a better way to prevent hack of this kind on your website.

`$data = $reques-&amp;gt;only([‘username’,’first_name’,’last_name’,’email’,’password’,’country’]);`

You can prevent it by using $request-&amp;gt;only() than in an array declare the inputs you want your backend to accept.

you can alternatively also use the PHP inbuilt function in_array(), you will just place the data you don't want to be in your request, and when found you can tell it to throw an error!.

I hope this helps you if you have any questions you can ask in the comment section below.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
    <item>
      <title>Answer: Error "Your push would publish a private email address"</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Wed, 21 Aug 2024 06:40:39 +0000</pubDate>
      <link>https://dev.to/developeralamin/answer-error-your-push-would-publish-a-private-email-address-h9k</link>
      <guid>https://dev.to/developeralamin/answer-error-your-push-would-publish-a-private-email-address-h9k</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/43863522/error-your-push-would-publish-a-private-email-address/45156966#45156966" rel="noopener noreferrer"&gt;
            &lt;span class="title-flare"&gt;answer&lt;/span&gt; re: Error "Your push would publish a private email address"
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Jul 18 '17&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/43863522/error-your-push-would-publish-a-private-email-address/45156966#45156966" rel="noopener noreferrer"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          122
        &lt;/div&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;&lt;strong&gt;Warning: This will expose your email address!&lt;/strong&gt; Each commit includes the email address of the committer and for public repositories, this information is publicly available.&lt;/p&gt;
&lt;p&gt;--&lt;/p&gt;
&lt;p&gt;I experienced the same &lt;code&gt;error: GH007&lt;/code&gt; message as well and used the following to resolve the issue.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to &lt;em&gt;&lt;a href="https://help.github.com/articles/setting-your-email-in-git/" rel="noreferrer noopener"&gt;Setting your commit email address&lt;/a&gt;&lt;/em&gt;…&lt;/li&gt;
&lt;/ol&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/43863522/error-your-push-would-publish-a-private-email-address/45156966#45156966" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Laravel logging</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Fri, 05 Jul 2024 17:20:30 +0000</pubDate>
      <link>https://dev.to/developeralamin/laravel-logging-32jm</link>
      <guid>https://dev.to/developeralamin/laravel-logging-32jm</guid>
      <description>&lt;p&gt;To help you learn more about what's happening within your application, Laravel provides robust logging services that allow you to log messages to files, the system error log, and even to Slack to notify your entire team.&lt;/p&gt;

&lt;p&gt;In this folder there have the log file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;storage/logs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can create laravel custom  log file. Go to the &lt;code&gt;config\logging.php&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;//By default have 
  'single' =&amp;gt; [
            'driver' =&amp;gt; 'single',
            'path' =&amp;gt; storage_path('logs/laravel.log'),
            'level' =&amp;gt; env('LOG_LEVEL', 'debug'),
            'replace_placeholders' =&amp;gt; true,
        ],

//here is the custom log example:

'custom' =&amp;gt; [
            'driver' =&amp;gt; 'single',
            'path' =&amp;gt; storage_path('logs/custom.log'),
            'level' =&amp;gt; env('LOG_LEVEL', 'debug'),
            'replace_placeholders' =&amp;gt; true,
        ],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we want to show the every log data show our custom log file . Edit the &lt;code&gt;.env&lt;/code&gt; file&lt;br&gt;
replace&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LOG_CHANNEL=stack to LOG_CHANNEL=custom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Displaying Unescaped Data on laravel blade file</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Mon, 27 May 2024 13:45:02 +0000</pubDate>
      <link>https://dev.to/developeralamin/displaying-unescaped-data-on-laravel-blade-file-11</link>
      <guid>https://dev.to/developeralamin/displaying-unescaped-data-on-laravel-blade-file-11</guid>
      <description>&lt;p&gt;By default, Blade statements are automatically sent through PHP's htmlspecialchars function to prevent XSS attacks. If you do not want your data to be escaped, you may use the following syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, {!! $name !!}.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>laravel</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Redirecting to External Domains from Laravel</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Mon, 27 May 2024 13:37:33 +0000</pubDate>
      <link>https://dev.to/developeralamin/redirecting-to-external-domains-from-laravel-2na7</link>
      <guid>https://dev.to/developeralamin/redirecting-to-external-domains-from-laravel-2na7</guid>
      <description>&lt;p&gt;Sometimes you may need to redirect to a domain outside of your application. You may do so by calling the away method, which creates a RedirectResponse without any additional URL encoding, validation, or verification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return redirect()-&amp;gt;away('https://www.google.com');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>laravel</category>
      <category>vue</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Deep Linking for Android and Apple in React.js</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Mon, 01 Apr 2024 16:53:10 +0000</pubDate>
      <link>https://dev.to/developeralamin/deep-linking-for-andriod-and-apple-in-reactjs-1hjc</link>
      <guid>https://dev.to/developeralamin/deep-linking-for-andriod-and-apple-in-reactjs-1hjc</guid>
      <description>&lt;p&gt;Today I will discuss about how to create Android &amp;amp; Apple Deeplinking.&lt;/p&gt;

&lt;h2&gt;
  
  
  For Android
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;You have &lt;code&gt;assetlinks.json&lt;/code&gt; file .&lt;/li&gt;
&lt;li&gt;Create "assetlinks.json" file. Include the file inside &lt;code&gt;public/.well-known&lt;/code&gt; folder .&lt;/li&gt;
&lt;li&gt;The route is --&amp;gt; &lt;code&gt;domainname/.well-known/assetlinks.json&lt;/code&gt; .&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  For Apple
&lt;/h2&gt;

&lt;p&gt;Unable to host static file apple-app-site-association from the react project root in locally . &lt;/p&gt;

&lt;h2&gt;
  
  
  Solutions :
&lt;/h2&gt;

&lt;p&gt;Need two file and paste this json on this file:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;public/.well-known/apple-app-site-association.&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;public/.well-known/apple-app-site-association.json&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "applinks": {
    "apps": [

    ],
    "details": [
      {
        "appID": "xxxxxxxx-xxxxxxxx",
        "paths": [
          "*",
          "/"
        ]
      }
    ]
  }
}

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

&lt;/div&gt;



&lt;p&gt;Using &lt;br&gt;
 1 . AWS Amplify&lt;br&gt;
I added the following to the top of my redirects on amplify&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "source": "/.well-known/apple-app-site-association",
    "target": "/.well-known/apple-app-site-association.json",
    "status": "200",
    "condition": null
},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;h2&gt;
  
  
  Add a redirect
&lt;/h2&gt;

&lt;p&gt;Finally, Apple expects this file to exist at the exact path &lt;code&gt;yourdomain.com/.well-known/apple-app-site-association&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test your app
&lt;/h2&gt;

&lt;p&gt;First, you'll need to make sure you publish your website on the domain you used.&lt;/p&gt;

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

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Deep Linking for Andriod and Apple in Next.js</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Sat, 30 Mar 2024 16:48:53 +0000</pubDate>
      <link>https://dev.to/developeralamin/deep-linking-for-andriod-and-apple-in-nextjs-1nmh</link>
      <guid>https://dev.to/developeralamin/deep-linking-for-andriod-and-apple-in-nextjs-1nmh</guid>
      <description>&lt;p&gt;Today I will discuss about how to create Android &amp;amp; Apple Deeplinking.&lt;/p&gt;

&lt;h2&gt;
  
  
  For Android
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;You have &lt;code&gt;assetlinks.json&lt;/code&gt; file .&lt;/li&gt;
&lt;li&gt;Create "assetlinks.json" file. Include the file inside &lt;code&gt;public/.well-known&lt;/code&gt; folder .&lt;/li&gt;
&lt;li&gt;The route is --&amp;gt; &lt;code&gt;domainname/.well-known/assetlinks.json&lt;/code&gt; .&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  For Apple
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Apple requires that your website has a file at the path &lt;code&gt;/.well-known/apple-app-site-association&lt;/code&gt; on your URL.&lt;/li&gt;
&lt;li&gt;Create an API route&lt;/li&gt;
&lt;li&gt;Create a file at this in your project location:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;pages/api/.well-known/apple-app-site-association.ts&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;import type { NextApiRequest, NextApiResponse } from 'next'

const BUNDLE_ID = 'YOUR-APPLE-APP-BUNDLE-ID' // replace with your bundle ID

const association = {
  applinks: {
    apps: [],
    details: [
      {
        appID: `${BUNDLE_ID}`,
        paths: ['*', "/"],
      },
    ],
  },
}

export default (_: NextApiRequest, response: NextApiResponse) =&amp;gt; {
  return response.status(200).send(association)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add a redirect
&lt;/h2&gt;

&lt;p&gt;Finally, Apple expects this file to exist at the exact path &lt;code&gt;yourdomain.com/.well-known/apple-app-site-association&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Since the file we created above is an API route, we need to create a redirect in next.config.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const nextConfig = {
  // ...
  async redirects() {
    return [
      {
        source: '/.well-known/:file',
        destination: '/api/.well-known/:file',
        permanent: false,
      },
    ]
  },
}

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test your app
&lt;/h2&gt;

&lt;p&gt;First, you'll need to make sure you publish your website on the domain you used.&lt;/p&gt;

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

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>How to use deep linking and Apple App Site Association with React.js</title>
      <dc:creator>Al-Amin Islam</dc:creator>
      <pubDate>Thu, 28 Mar 2024 08:23:04 +0000</pubDate>
      <link>https://dev.to/developeralamin/how-to-use-deep-linking-and-apple-app-site-association-with-reactjs-1cnm</link>
      <guid>https://dev.to/developeralamin/how-to-use-deep-linking-and-apple-app-site-association-with-reactjs-1cnm</guid>
      <description>&lt;p&gt;I have been looking far and wide and I can't seem to find any information about how to properly use apple-app-site-association/deep linking with a react.js website. I have already solve andriod deep-linking . I am set up assetlink in my project (public/.well-known/assetlinks.json). But how to use apple-app-site-association.&lt;/p&gt;

</description>
      <category>react</category>
    </item>
  </channel>
</rss>
