<?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: Arafat Hossain Ar</title>
    <description>The latest articles on DEV Community by Arafat Hossain Ar (@arafatweb).</description>
    <link>https://dev.to/arafatweb</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F695640%2F11046860-b16c-4262-9ed3-e74e0b948ec0.jpg</url>
      <title>DEV Community: Arafat Hossain Ar</title>
      <link>https://dev.to/arafatweb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arafatweb"/>
    <language>en</language>
    <item>
      <title>How to Build a Neural Network From Scratch in Python</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Sun, 11 Oct 2026 11:57:09 +0000</pubDate>
      <link>https://dev.to/arafatweb/how-to-build-a-neural-network-from-scratch-in-python-1em1</link>
      <guid>https://dev.to/arafatweb/how-to-build-a-neural-network-from-scratch-in-python-1em1</guid>
      <description>&lt;p&gt;Want to understand how artificial intelligence works beyond calling a library function? One way to learn is to build a small neural network yourself.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will build a neural network from scratch using pure Python. We will not use TensorFlow, PyTorch, NumPy, or scikit-learn. Everything, including the forward pass, loss calculation, backpropagation, and weight updates, will be implemented using Python's standard library.&lt;/p&gt;

&lt;p&gt;Our project will predict whether a student passes an exam based on the number of hours they studied. We will train the model on a small dataset and then test it on examples it has not seen during training.&lt;/p&gt;

&lt;p&gt;I also ran the program in VS Code and included the actual output so you can compare your results with mine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What We Are Building&lt;/li&gt;
&lt;li&gt;Set Up the Python Project&lt;/li&gt;
&lt;li&gt;Prepare the Dataset&lt;/li&gt;
&lt;li&gt;Build a Neural Network From Scratch&lt;/li&gt;
&lt;li&gt;Train the Neural Network&lt;/li&gt;
&lt;li&gt;Test the Model and Check the Results&lt;/li&gt;
&lt;li&gt;How the Neural Network Works&lt;/li&gt;
&lt;li&gt;Limitations and Experiments&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. What We Are Building
&lt;/h2&gt;

&lt;p&gt;Imagine we have a dataset containing students' study hours and exam results.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Study hours&lt;/th&gt;
&lt;th&gt;Exam result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Fail&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Fail&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Fail&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We could write a simple rule that predicts a pass whenever someone studies for at least five hours. However, that would be a rule we decided on ourselves.&lt;/p&gt;

&lt;p&gt;Instead, we will create a neural network that learns from examples by adjusting numerical values called weights and biases.&lt;/p&gt;

&lt;p&gt;The training process follows this general sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Training Data
     |
     v
Make a Prediction
     |
     v
Calculate the Error
     |
     v
Update Weights and Biases
     |
     v
Repeat Training
     |
     v
Test on Unseen Examples
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The network does not rewrite its Python code while learning. It changes the numerical parameters used to calculate its predictions.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Set Up the Python Project
&lt;/h2&gt;

&lt;p&gt;You need Python 3 and a code editor. I used VS Code to run this project.&lt;/p&gt;

&lt;p&gt;Create a folder containing these two files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python-ai-from-scratch/
├── dataset.csv
└── ai.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check your Python installation in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will use three built-in Python modules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;csv&lt;/code&gt; to read the dataset.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;math&lt;/code&gt; to perform mathematical calculations.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;random&lt;/code&gt; to initialize weights and shuffle training examples.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You do not need to install any third-party packages.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Prepare the Dataset
&lt;/h2&gt;

&lt;p&gt;Create a file named &lt;code&gt;dataset.csv&lt;/code&gt; and add the following data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;study_hours,passed,split
1,0,train
2,0,train
2.5,0,train
3,0,train
3.5,0,test
4,0,train
4.5,1,train
5,1,train
5.5,1,test
6,1,train
7,1,train
8,1,test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The dataset contains three columns.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;study_hours&lt;/code&gt; represents the number of hours a student studied.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;passed&lt;/code&gt; contains the expected result. A value of &lt;code&gt;0&lt;/code&gt; means fail, while &lt;code&gt;1&lt;/code&gt; means pass.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;split&lt;/code&gt; identifies whether a row belongs to the training set or the test set.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The model will learn from the training rows. The three rows marked &lt;code&gt;test&lt;/code&gt; will be kept separate until evaluation.&lt;/p&gt;

&lt;p&gt;These are synthetic examples created for this tutorial. They are not real student records, and they should not be used to draw conclusions about actual exam performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Build a Neural Network From Scratch
&lt;/h2&gt;

&lt;p&gt;Now open &lt;code&gt;ai.py&lt;/code&gt; and add the complete implementation below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;

&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sigmoid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;leaky_relu&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Keep a small gradient when the input is negative.
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;load_dataset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;train_features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;train_labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;test_features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;test_labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newline&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;reader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DictReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;hours&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;study_hours&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

            &lt;span class="c1"&gt;# Scale study hours to a range from 0 to 1.
&lt;/span&gt;            &lt;span class="n"&gt;feature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hours&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;passed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;split&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;train&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;train_features&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;train_labels&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;test_features&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;test_labels&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;train_features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;train_labels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;test_features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;test_labels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NeuralNetwork&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Four neurons in the hidden layer.
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hidden_weights&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hidden_biases&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;

        &lt;span class="c1"&gt;# One output neuron.
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_weights&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_bias&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;forward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;hidden&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;weights&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bias&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hidden_weights&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hidden_biases&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;weight&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;
                &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;weights&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;bias&lt;/span&gt;

            &lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;leaky_relu&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

        &lt;span class="n"&gt;output_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;weight&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_weights&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hidden&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_bias&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;sigmoid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_loss&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;total_loss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;prediction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="c1"&gt;# Avoid taking the logarithm of zero.
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prediction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1e-7&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;1e-7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="n"&gt;total_loss&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p&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="n"&gt;total_loss&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;train&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;epochs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;epoch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;epochs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="c1"&gt;# Shuffle training examples for each epoch.
&lt;/span&gt;            &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
            &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;inputs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

                &lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prediction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

                &lt;span class="c1"&gt;# Calculate the error at the output layer.
&lt;/span&gt;                &lt;span class="n"&gt;output_error&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prediction&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;

                &lt;span class="c1"&gt;# Preserve the old weights for backpropagation.
&lt;/span&gt;                &lt;span class="n"&gt;old_output_weights&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_weights&lt;/span&gt;&lt;span class="p"&gt;[:]&lt;/span&gt;

                &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_weights&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
                    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_weights&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;output_error&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                    &lt;span class="p"&gt;)&lt;/span&gt;

                &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_bias&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;output_error&lt;/span&gt;

                &lt;span class="c1"&gt;# Propagate the error through the hidden layer.
&lt;/span&gt;                &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hidden_weights&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
                    &lt;span class="n"&gt;activation_gradient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;
                    &lt;span class="p"&gt;)&lt;/span&gt;

                    &lt;span class="n"&gt;hidden_error&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="n"&gt;output_error&lt;/span&gt;
                        &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;old_output_weights&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                        &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;activation_gradient&lt;/span&gt;
                    &lt;span class="p"&gt;)&lt;/span&gt;

                    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hidden_weights&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;hidden_error&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                    &lt;span class="p"&gt;)&lt;/span&gt;

                    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hidden_biases&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;hidden_error&lt;/span&gt;
                    &lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="c1"&gt;# Calculate loss after completing the epoch.
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;epoch&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;loss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;calculate_loss&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Epoch &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;epoch&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
                    &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Training loss = &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;train_features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;train_labels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;test_features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;test_labels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_dataset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dataset.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;NeuralNetwork&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;train&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;train_features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;train_labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Test results:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;correct&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;actual&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_labels&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;probability&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;predicted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;probability&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;predicted&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;actual&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;correct&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Study hours: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Actual: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;actual&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Predicted: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;predicted&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Score: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;probability&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;accuracy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;correct&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Test accuracy: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;accuracy&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;(&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;correct&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file and run the project from your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python ai.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what the main methods do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;load_dataset()&lt;/code&gt; reads the CSV file and separates training data from test data.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;forward()&lt;/code&gt; calculates the network's output.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;predict()&lt;/code&gt; returns the output score for an input.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;calculate_loss()&lt;/code&gt; measures the model's prediction error.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;train()&lt;/code&gt; updates the network's weights and biases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each method has a specific responsibility, which makes the code easier to understand and modify.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Train the Neural Network
&lt;/h2&gt;

&lt;p&gt;Training means adjusting the network's parameters so that its predictions become closer to the expected answers.&lt;/p&gt;

&lt;p&gt;The model starts with randomly initialized weights. During training, it processes examples, calculates prediction errors, and updates its parameters.&lt;/p&gt;

&lt;p&gt;Consider this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;output_error&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prediction&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the expected result is &lt;code&gt;1&lt;/code&gt; but the model predicts &lt;code&gt;0.3&lt;/code&gt;, the error is negative. The training update uses this information to move the parameters in a direction intended to reduce the loss.&lt;/p&gt;

&lt;p&gt;Two important concepts are involved here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backpropagation&lt;/strong&gt; calculates how the prediction error relates to parameters in the network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gradient descent&lt;/strong&gt; uses those calculations to update the parameters.&lt;/p&gt;

&lt;p&gt;The learning rate controls the size of each update:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;train&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;train_features&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;train_labels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;epochs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A learning rate that is too large can make training unstable. A rate that is too small can make training progress slowly.&lt;/p&gt;

&lt;p&gt;The code trains for 3,000 epochs and prints the training loss every 500 epochs. The loss is calculated after the updates for that epoch have finished.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Test the Model and Check the Results
&lt;/h2&gt;

&lt;p&gt;After training, the program evaluates the three examples that were excluded from the training set.&lt;/p&gt;

&lt;p&gt;For each example, it prints the study hours, actual label, predicted label, and output score.&lt;/p&gt;

&lt;p&gt;I ran this implementation in VS Code. Here is the actual output from my run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Epoch 0: Training loss = 0.6799
Epoch 500: Training loss = 0.0387
Epoch 1000: Training loss = 0.0099
Epoch 1500: Training loss = 0.0053
Epoch 2000: Training loss = 0.0035
Epoch 2500: Training loss = 0.0026

Test results:
Study hours: 3.5, Actual: 0, Predicted: 0, Score: 0.0009
Study hours: 5.5, Actual: 1, Predicted: 1, Score: 1.0000
Study hours: 8, Actual: 1, Predicted: 1, Score: 1.0000

Test accuracy: 100% (3/3)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The training loss decreased from &lt;code&gt;0.6799&lt;/code&gt; at epoch 0 to &lt;code&gt;0.0026&lt;/code&gt; at epoch 2500. This shows that the model became much better at fitting the training examples.&lt;/p&gt;

&lt;p&gt;The three test predictions were also correct:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Study hours&lt;/th&gt;
&lt;th&gt;Actual result&lt;/th&gt;
&lt;th&gt;Predicted result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;3.5&lt;/td&gt;
&lt;td&gt;Fail&lt;/td&gt;
&lt;td&gt;Fail&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5.5&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The program reports 100% test accuracy because it correctly classified all three test examples.&lt;/p&gt;

&lt;p&gt;Accuracy is calculated using this formula:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Accuracy (%) = (Correct Predictions / Total Test Examples) * 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For this run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Accuracy (%) = (3 / 3) * 100
Accuracy (%) = 100%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The score values are displayed to four decimal places. Therefore, a printed score of &lt;code&gt;1.0000&lt;/code&gt; may be a value very close to 1 rather than exactly 1.&lt;/p&gt;

&lt;p&gt;There is also an important limitation to keep in mind. The test set contains only three examples. If the model got one prediction wrong, its accuracy would fall to 66.67%.&lt;/p&gt;

&lt;p&gt;These results show that the program ran and classified this small test set correctly. They do not prove that it will perform equally well on new or real-world data.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. How the Neural Network Works
&lt;/h2&gt;

&lt;p&gt;The implementation uses a few mathematical operations to turn input data into predictions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Forward propagation
&lt;/h3&gt;

&lt;p&gt;Forward propagation passes the input through the hidden layer and then the output layer. Each neuron combines its inputs with weights and adds a bias.&lt;/p&gt;

&lt;p&gt;The final output is a score between zero and one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Leaky ReLU
&lt;/h3&gt;

&lt;p&gt;The hidden neurons use Leaky ReLU as their activation function.&lt;/p&gt;

&lt;p&gt;For a positive input, the function returns the input unchanged. For a negative input, it returns a small negative value instead of zero.&lt;/p&gt;

&lt;p&gt;This small slope allows gradients to continue flowing through negative activations, reducing the risk of permanently inactive neurons.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sigmoid
&lt;/h3&gt;

&lt;p&gt;The output neuron uses the sigmoid function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sigmoid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sigmoid converts a number into a value between zero and one. The model uses &lt;code&gt;0.5&lt;/code&gt; as its classification threshold:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A score below &lt;code&gt;0.5&lt;/code&gt; becomes class &lt;code&gt;0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A score equal to or above &lt;code&gt;0.5&lt;/code&gt; becomes class &lt;code&gt;1&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Loss calculation
&lt;/h3&gt;

&lt;p&gt;The network uses binary cross-entropy to measure how far its predictions are from the expected labels.&lt;/p&gt;

&lt;p&gt;A lower loss generally means the model fits the training examples better. However, a low training loss does not guarantee good performance on unseen data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Backpropagation and gradient descent
&lt;/h3&gt;

&lt;p&gt;Backpropagation calculates the gradients needed to update the network's parameters. Gradient descent then uses those gradients and the learning rate to change the weights and biases.&lt;/p&gt;

&lt;p&gt;Together, these steps allow the model to learn from examples without manually writing a rule for every possible input.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Limitations and Experiments
&lt;/h2&gt;

&lt;p&gt;This project is intentionally small. It uses one input feature, four hidden neurons, nine training examples, and three test examples.&lt;/p&gt;

&lt;p&gt;The dataset is synthetic, and the test set is too small to provide strong evidence of generalization. The results should be treated as a demonstration of how a neural network works, not as a reliable exam prediction system.&lt;/p&gt;

&lt;p&gt;Here are a few experiments you can try:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Change the learning rate from &lt;code&gt;0.1&lt;/code&gt; to &lt;code&gt;0.01&lt;/code&gt; and compare the training loss.&lt;/li&gt;
&lt;li&gt;Increase the number of hidden neurons and see how the training results change.&lt;/li&gt;
&lt;li&gt;Add more examples to the dataset and reserve a larger test set.&lt;/li&gt;
&lt;li&gt;Add more input features, if you have suitable data.&lt;/li&gt;
&lt;li&gt;Save the trained weights and biases so you can reuse the model without training it again.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Change one setting at a time and record what happens. That makes it easier to understand which change caused a difference.&lt;/p&gt;

&lt;p&gt;This project is also very different from a large language model. Modern language models use much larger networks, extensive training datasets, and substantial computing resources. Still, the basic ideas of parameters, predictions, loss, and optimization are useful starting points for understanding them.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Final Thoughts
&lt;/h2&gt;

&lt;p&gt;We have built a small neural network from scratch using Python's standard library. It reads a dataset, makes predictions, calculates errors, updates its parameters, and evaluates its predictions on separate test examples.&lt;/p&gt;

&lt;p&gt;The most useful part of this exercise is being able to inspect the calculations instead of treating model training as a black box.&lt;/p&gt;

&lt;p&gt;Start by changing the learning rate, run the program again, and compare the results. Once you understand this version, you can move on to larger datasets and more advanced neural network architectures.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>learning</category>
      <category>data</category>
    </item>
    <item>
      <title>Building a Personal Blog with Laravel: A Real World Project</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Sun, 23 Aug 2026 12:26:47 +0000</pubDate>
      <link>https://dev.to/arafatweb/building-a-personal-blog-with-laravel-a-real-world-project-4mhp</link>
      <guid>https://dev.to/arafatweb/building-a-personal-blog-with-laravel-a-real-world-project-4mhp</guid>
      <description>&lt;p&gt;A personal blog sounds like a simple Laravel project. Create posts, show them on the homepage, and you are done.&lt;/p&gt;

&lt;p&gt;But once you start adding search, categories, tags, comments, SEO, authentication, analytics, and an admin panel, things become much more interesting.&lt;/p&gt;

&lt;p&gt;I built this Laravel Personal Blog as a real world project to explore those problems instead of building another basic CRUD application.&lt;/p&gt;

&lt;p&gt;The complete source code is available on GitHub:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/arafat-web/laravel-personal-blog" rel="noopener noreferrer"&gt;https://github.com/arafat-web/laravel-personal-blog&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What Is This Project?&lt;/li&gt;
&lt;li&gt;Technology Stack&lt;/li&gt;
&lt;li&gt;Main Features&lt;/li&gt;
&lt;li&gt;Project Structure&lt;/li&gt;
&lt;li&gt;How Visitor Analytics Works&lt;/li&gt;
&lt;li&gt;SEO and Content Management&lt;/li&gt;
&lt;li&gt;How to Run the Project&lt;/li&gt;
&lt;li&gt;What I Learned&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What Is This Project?
&lt;/h2&gt;

&lt;p&gt;This is a complete single-author blogging platform built with Laravel.&lt;/p&gt;

&lt;p&gt;It includes both a public blog and a custom admin panel. The project was built without additional application packages, so most of the important functionality is visible in the codebase itself.&lt;/p&gt;

&lt;p&gt;The public side contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Homepage&lt;/li&gt;
&lt;li&gt;Blog posts&lt;/li&gt;
&lt;li&gt;Categories&lt;/li&gt;
&lt;li&gt;Tags&lt;/li&gt;
&lt;li&gt;Search&lt;/li&gt;
&lt;li&gt;Comments&lt;/li&gt;
&lt;li&gt;RSS feed&lt;/li&gt;
&lt;li&gt;Sitemap&lt;/li&gt;
&lt;li&gt;SEO metadata&lt;/li&gt;
&lt;li&gt;Post view tracking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The admin panel contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dashboard&lt;/li&gt;
&lt;li&gt;Post management&lt;/li&gt;
&lt;li&gt;Category and tag management&lt;/li&gt;
&lt;li&gt;Comment moderation&lt;/li&gt;
&lt;li&gt;User management&lt;/li&gt;
&lt;li&gt;General settings&lt;/li&gt;
&lt;li&gt;SEO settings&lt;/li&gt;
&lt;li&gt;Visitor analytics&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Technology Stack
&lt;/h2&gt;

&lt;p&gt;The project uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PHP 8.3+
Laravel 13.17
MySQL or SQLite
Blade
Eloquent ORM
JavaScript
CSS
PHPUnit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The current project configuration requires PHP 8.3 and Laravel 13.17.&lt;/p&gt;

&lt;h2&gt;
  
  
  Main Features
&lt;/h2&gt;

&lt;p&gt;The project goes beyond basic CRUD.&lt;/p&gt;

&lt;p&gt;For example, posts can have categories, tags, comments, authors, featured images, publishing status, and view counts.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Post&lt;/code&gt; model defines these relationships using Eloquent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;BelongsTo&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;belongsTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;categories&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;BelongsToMany&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;belongsToMany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Category&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;BelongsToMany&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;belongsToMany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Tag&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;HasMany&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;hasMany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Comment&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model also has a &lt;code&gt;published()&lt;/code&gt; scope, so the application can easily retrieve only published posts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Structure
&lt;/h2&gt;

&lt;p&gt;The application keeps the normal Laravel structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app/
├── Http/
│   ├── Controllers/
│   └── Middleware/
├── Models/
└── Providers/

database/
├── factories/
├── migrations/
└── seeders/

resources/
└── views/
    ├── admin/
    └── blog/

public/
├── css/
└── js/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This keeps the public blog, admin panel, models, middleware, and views separated by responsibility.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Visitor Analytics Works
&lt;/h2&gt;

&lt;p&gt;One of the more interesting parts of the project is visitor tracking.&lt;/p&gt;

&lt;p&gt;Instead of simply increasing a counter every time someone opens a page, the application uses middleware to decide whether a request should count as a visit.&lt;/p&gt;

&lt;p&gt;The flow is roughly:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyf0llruj2wp4i4wssya5.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyf0llruj2wp4i4wssya5.png" alt="visitors count flow" width="800" height="1120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The middleware checks for bots, AJAX requests, JSON requests, and machine-readable endpoints such as the sitemap and RSS feed. It also uses a visitor cookie and IP fallback to prevent repeated requests from being counted as separate visits.&lt;/p&gt;

&lt;p&gt;This is a good example of the difference between building a demo and building something closer to a real application.&lt;/p&gt;

&lt;h2&gt;
  
  
  SEO and Content Management
&lt;/h2&gt;

&lt;p&gt;A blog is not very useful if search engines cannot understand it.&lt;/p&gt;

&lt;p&gt;The project includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Meta descriptions&lt;/li&gt;
&lt;li&gt;Keywords&lt;/li&gt;
&lt;li&gt;Open Graph tags&lt;/li&gt;
&lt;li&gt;Twitter cards&lt;/li&gt;
&lt;li&gt;JSON-LD&lt;/li&gt;
&lt;li&gt;Sitemap&lt;/li&gt;
&lt;li&gt;robots.txt&lt;/li&gt;
&lt;li&gt;Search&lt;/li&gt;
&lt;li&gt;SEO settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These settings can be managed from the admin panel.&lt;/p&gt;

&lt;p&gt;The project also includes comments with a moderation system, which is important for a public blog.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Run the Project
&lt;/h2&gt;

&lt;p&gt;Clone the repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/arafat-web/laravel-personal-blog.git
&lt;span class="nb"&gt;cd &lt;/span&gt;laravel-personal-blog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the environment file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
php artisan key:generate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configure your database in &lt;code&gt;.env&lt;/code&gt;, then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan migrate &lt;span class="nt"&gt;--seed&lt;/span&gt;
php artisan storage:link
php artisan serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The seeder creates sample content and an admin account. The repository README contains the default development credentials.&lt;/p&gt;

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

&lt;p&gt;The biggest lesson from this project was that a real application is much more than CRUD.&lt;/p&gt;

&lt;p&gt;Creating a post is easy.&lt;/p&gt;

&lt;p&gt;The interesting problems appear afterward.&lt;/p&gt;

&lt;p&gt;How should visitors be counted?&lt;/p&gt;

&lt;p&gt;How should bots be handled?&lt;/p&gt;

&lt;p&gt;How should comments be moderated?&lt;/p&gt;

&lt;p&gt;How should SEO be managed?&lt;/p&gt;

&lt;p&gt;How should drafts stay hidden?&lt;/p&gt;

&lt;p&gt;How should everything be tested?&lt;/p&gt;

&lt;p&gt;These are the problems that make a project worth building.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;This project started as a personal blog, but it became a practical Laravel project covering authentication, Eloquent relationships, middleware, SEO, analytics, content management, storage, and testing.&lt;/p&gt;

&lt;p&gt;If you are learning Laravel, projects like this are useful because you can see how individual Laravel features come together to form a complete application.&lt;/p&gt;

&lt;p&gt;The full source code is available here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/arafat-web/laravel-personal-blog" rel="noopener noreferrer"&gt;https://github.com/arafat-web/laravel-personal-blog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use it as a reference, experiment with the existing features, or build your own version on top of it.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How to Use AI Without Ruining Your Programming Skills</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Wed, 18 Feb 2026 08:25:55 +0000</pubDate>
      <link>https://dev.to/arafatweb/how-to-use-ai-without-ruining-your-programming-skills-2538</link>
      <guid>https://dev.to/arafatweb/how-to-use-ai-without-ruining-your-programming-skills-2538</guid>
      <description>&lt;p&gt;AI tools are everywhere now. From code suggestions to instant bug fixes, it feels like you can build things faster than ever. For many developers, especially juniors, AI looks like the perfect shortcut.&lt;/p&gt;

&lt;p&gt;When I first started using AI while coding, it felt helpful and dangerous at the same time. Helpful because problems got solved quickly. Dangerous because I noticed I was thinking less and pasting more.&lt;/p&gt;

&lt;p&gt;In this blog, I will explain how to use AI &lt;strong&gt;as a learning partner instead of a replacement&lt;/strong&gt;, so your programming skills grow instead of slowly fading away.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Table of Contents&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why AI Feels So Powerful&lt;/li&gt;
&lt;li&gt;Where AI Actually Helps Developers&lt;/li&gt;
&lt;li&gt;How AI Can Quietly Harm Your Skills&lt;/li&gt;
&lt;li&gt;Rules for Using AI the Right Way&lt;/li&gt;
&lt;li&gt;A Real World Analogy&lt;/li&gt;
&lt;li&gt;Practical AI Usage Examples&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why AI Feels So Powerful&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;AI tools feel powerful because they remove friction.&lt;/p&gt;

&lt;p&gt;You write a prompt, and suddenly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Errors are explained&lt;/li&gt;
&lt;li&gt;Code is generated&lt;/li&gt;
&lt;li&gt;Logic is suggested&lt;/li&gt;
&lt;li&gt;Bugs disappear&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This creates a false sense of mastery. Things work, but you may not fully understand why they work. That gap is where skills quietly weaken.&lt;/p&gt;

&lt;p&gt;AI feels fast. Learning is slow. Most people choose speed without realizing the cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Where AI Actually Helps Developers&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;AI is not the enemy. Used correctly, it can make you a better developer.&lt;/p&gt;

&lt;p&gt;AI is genuinely useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Explaining unfamiliar concepts in simple language&lt;/li&gt;
&lt;li&gt;Refactoring code after you write it&lt;/li&gt;
&lt;li&gt;Pointing out edge cases you missed&lt;/li&gt;
&lt;li&gt;Summarizing documentation&lt;/li&gt;
&lt;li&gt;Reviewing logic for readability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Explain why this loop is slow and how to improve it”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;is very different from asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Write the whole solution for me”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One builds understanding. The other replaces it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How AI Can Quietly Harm Your Skills&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The danger is not obvious at first.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;You stop struggling&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Struggle is where learning happens. If AI solves every problem instantly, your brain never builds problem-solving muscles.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;You stop debugging&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Debugging teaches you how systems behave under pressure. Skipping it removes one of the most important developer skills.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;You lose architectural thinking&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AI is good at small solutions. It is not responsible for your system design. If you rely on it too much, your big-picture thinking weakens.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;You become prompt-dependent&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you cannot code without asking AI first, your confidence and independence disappear.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Rules for Using AI the Right Way&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;These rules are simple, but powerful.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Rule 1: Think First, Ask Second&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Always try to solve the problem yourself first. Even a bad attempt is valuable.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Rule 2: Ask for Explanations, Not Solutions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Ask AI to explain why something works instead of generating full code.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Rule 3: Rewrite AI Code in Your Own Words&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If AI gives code, rewrite it manually. If you cannot rewrite it, you did not understand it.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Rule 4: Never Skip Fundamentals&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AI does not replace understanding loops, memory, databases, or networking. You still need those foundations.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Rule 5: Debug Without AI Sometimes&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Force yourself to debug issues without AI. This keeps your instincts sharp.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;A Real World Analogy&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Think of AI like a calculator.&lt;/p&gt;

&lt;p&gt;A calculator is useful, but if you never learn basic math, you will not understand whether the result makes sense.&lt;/p&gt;

&lt;p&gt;AI is the same. It can assist, but it cannot replace understanding. If you trust it blindly, you lose the ability to judge correctness.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Practical AI Usage Examples&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Good AI Usage&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;“Explain why this query is slow”&lt;/li&gt;
&lt;li&gt;“What edge cases should I consider here?”&lt;/li&gt;
&lt;li&gt;“Can you review this code for readability?”&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Bad AI Usage&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;“Build the entire feature for me”&lt;/li&gt;
&lt;li&gt;“Fix this without explaining why”&lt;/li&gt;
&lt;li&gt;“Write production code I do not understand”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The difference is intention. Learning-focused prompts grow skills. Shortcut-focused prompts weaken them.&lt;/p&gt;

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

&lt;p&gt;AI is not replacing developers. It is exposing how developers learn.&lt;/p&gt;

&lt;p&gt;If you use AI to think less, your skills will decline. If you use AI to understand more, your skills will grow faster than before.&lt;/p&gt;

&lt;p&gt;The goal is not to avoid AI. The goal is to stay mentally involved while using it.&lt;/p&gt;

&lt;p&gt;AI should feel like a senior developer sitting next to you, explaining things. The moment it feels like a crutch, you are using it the wrong way.&lt;/p&gt;

&lt;p&gt;The future belongs to developers who can think, not just prompt.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>productivity</category>
      <category>career</category>
    </item>
    <item>
      <title>Is PHP Still a Valuable Programming Language in 2026?</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Tue, 27 Jan 2026 05:44:19 +0000</pubDate>
      <link>https://dev.to/arafatweb/is-php-still-a-valuable-programming-language-in-2026-3449</link>
      <guid>https://dev.to/arafatweb/is-php-still-a-valuable-programming-language-in-2026-3449</guid>
      <description>&lt;p&gt;PHP is one of those programming languages everyone seems to have an opinion about. Some say it is outdated. Some say it is dying. Others quietly keep building real products with it every single day.&lt;/p&gt;

&lt;p&gt;When I first started with PHP, I also wondered whether learning it was a good long-term decision. With new languages and frameworks appearing every year, it is a fair question to ask.&lt;/p&gt;

&lt;p&gt;In this blog, I will break down whether PHP is still a valuable programming language in 2026, using real-world context instead of internet noise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why People Think PHP Is Dying&lt;/li&gt;
&lt;li&gt;Where PHP Is Still Strong&lt;/li&gt;
&lt;li&gt;How PHP Has Evolved&lt;/li&gt;
&lt;li&gt;PHP in Real Production Systems&lt;/li&gt;
&lt;li&gt;Career Perspective for Developers&lt;/li&gt;
&lt;li&gt;When PHP Is a Bad Choice&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why People Think PHP Is Dying
&lt;/h2&gt;

&lt;p&gt;PHP has been around for a long time, and that alone makes people suspicious. Many developers associate PHP with old codebases, messy scripts, and poor practices from the past.&lt;/p&gt;

&lt;p&gt;Some common reasons people think PHP is no longer relevant:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They worked with legacy PHP code and had a bad experience&lt;/li&gt;
&lt;li&gt;They compare PHP to newer languages without context&lt;/li&gt;
&lt;li&gt;They assume popularity on social media equals real-world usage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The truth is, most of these opinions come from outdated experiences, not modern PHP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where PHP Is Still Strong
&lt;/h2&gt;

&lt;p&gt;PHP still dominates areas that actually matter in production.&lt;/p&gt;

&lt;p&gt;It powers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A large percentage of the web&lt;/li&gt;
&lt;li&gt;Content-heavy platforms&lt;/li&gt;
&lt;li&gt;Backend systems for SaaS products&lt;/li&gt;
&lt;li&gt;CMS-driven businesses&lt;/li&gt;
&lt;li&gt;APIs and internal tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Frameworks like Laravel have changed how PHP applications are structured, tested, and maintained. Modern PHP projects look nothing like the old scripts people complain about.&lt;/p&gt;

&lt;p&gt;PHP excels when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need fast development&lt;/li&gt;
&lt;li&gt;You want predictable hosting&lt;/li&gt;
&lt;li&gt;You are building web-first applications&lt;/li&gt;
&lt;li&gt;You want a mature ecosystem&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How PHP Has Evolved
&lt;/h2&gt;

&lt;p&gt;One mistake people make is judging PHP based on how it worked ten years ago.&lt;/p&gt;

&lt;p&gt;Modern PHP includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Strong typing options&lt;/li&gt;
&lt;li&gt;Improved performance&lt;/li&gt;
&lt;li&gt;Better memory handling&lt;/li&gt;
&lt;li&gt;Cleaner syntax&lt;/li&gt;
&lt;li&gt;Mature tooling and standards&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example of modern PHP style:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserService&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;UserRepository&lt;/span&gt; &lt;span class="nv"&gt;$repository&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;findActiveUsers&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getActive&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This looks and behaves like modern backend code, not a scripting language from the past.&lt;/p&gt;

&lt;p&gt;PHP today is structured, readable, and scalable when written properly.&lt;/p&gt;

&lt;h2&gt;
  
  
  PHP in Real Production Systems
&lt;/h2&gt;

&lt;p&gt;This is where the discussion usually ends.&lt;/p&gt;

&lt;p&gt;Large companies do not choose technologies based on trends. They choose what works.&lt;/p&gt;

&lt;p&gt;PHP is used in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Large-scale e-commerce platforms&lt;/li&gt;
&lt;li&gt;High-traffic news websites&lt;/li&gt;
&lt;li&gt;Financial systems&lt;/li&gt;
&lt;li&gt;Internal enterprise tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If PHP was truly dying, companies would be migrating away from it in large numbers. That is not happening.&lt;/p&gt;

&lt;p&gt;Instead, many teams are modernizing PHP codebases rather than replacing them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Career Perspective for Developers
&lt;/h2&gt;

&lt;p&gt;From a career point of view, PHP is still a strong option in 2026.&lt;/p&gt;

&lt;p&gt;Why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There is consistent demand&lt;/li&gt;
&lt;li&gt;Many businesses already rely on PHP&lt;/li&gt;
&lt;li&gt;PHP developers are needed to maintain and improve existing systems&lt;/li&gt;
&lt;li&gt;Laravel skills translate well into backend architecture thinking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PHP may not always be the trendiest language, but it pays bills, builds products, and solves problems.&lt;/p&gt;

&lt;p&gt;For junior developers, PHP is also easier to enter compared to lower-level backend languages.&lt;/p&gt;

&lt;h2&gt;
  
  
  When PHP Is a Bad Choice
&lt;/h2&gt;

&lt;p&gt;Being honest matters.&lt;/p&gt;

&lt;p&gt;PHP is not ideal when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need heavy real-time systems&lt;/li&gt;
&lt;li&gt;You are building game engines&lt;/li&gt;
&lt;li&gt;You require extremely low-level performance control&lt;/li&gt;
&lt;li&gt;Your team is already deeply invested in another ecosystem&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every language has limits. PHP is no exception.&lt;/p&gt;

&lt;p&gt;Choosing PHP should be a conscious decision, not an automatic one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;PHP is not dying. It is not outdated. It is not irrelevant.&lt;/p&gt;

&lt;p&gt;PHP is stable, mature, and practical.&lt;/p&gt;

&lt;p&gt;In 2026, PHP continues to be valuable for developers who care about building real applications rather than chasing trends. The language has evolved, the ecosystem is strong, and the demand is steady.&lt;/p&gt;

&lt;p&gt;If you learn PHP properly and pair it with modern practices, you are not falling behind. You are building skills that still matter.&lt;/p&gt;

&lt;p&gt;The real question is not whether PHP is valuable.&lt;br&gt;
The real question is whether you are writing PHP the right way.&lt;/p&gt;

&lt;p&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/arafatweb" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/arafatweb&lt;/a&gt;&lt;br&gt;
Portfolio: &lt;a href="https://arafatdev.com/" rel="noopener noreferrer"&gt;https://arafatdev.com/&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/arafat-web" rel="noopener noreferrer"&gt;https://github.com/arafat-web&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>programming</category>
      <category>2026</category>
    </item>
    <item>
      <title>Top 10 VS Code Extensions for PHP Developers in 2026</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Sun, 25 Jan 2026 06:28:22 +0000</pubDate>
      <link>https://dev.to/arafatweb/top-10-vs-code-extensions-for-php-developers-in-2026-199m</link>
      <guid>https://dev.to/arafatweb/top-10-vs-code-extensions-for-php-developers-in-2026-199m</guid>
      <description>&lt;p&gt;PHP remains a core language for backend development, powering applications from small websites to large enterprise systems. Visual Studio Code has become the editor of choice for many PHP developers because of its speed, flexibility, and strong extension ecosystem.&lt;/p&gt;

&lt;p&gt;When I first started using VS Code for PHP, choosing the right extensions was confusing. There were dozens of options, many overlapping, and some already outdated. Over time, I narrowed things down to a small set of extensions that genuinely improve productivity, reduce bugs, and make PHP development smoother.&lt;/p&gt;

&lt;p&gt;In this blog, I’ll walk through the &lt;strong&gt;top 10 VS Code extensions for PHP developers in 2026&lt;/strong&gt;, explain why they matter, and how they help in real-world projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;PHP Intelephense&lt;/li&gt;
&lt;li&gt;PHP CS Fixer&lt;/li&gt;
&lt;li&gt;PHP Debug (Xdebug)&lt;/li&gt;
&lt;li&gt;Laravel (Official)&lt;/li&gt;
&lt;li&gt;Blade Snippets&lt;/li&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;li&gt;GitLens&lt;/li&gt;
&lt;li&gt;Code Runner&lt;/li&gt;
&lt;li&gt;EditorConfig for VS Code&lt;/li&gt;
&lt;li&gt;Thunder Client&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. PHP Intelephense
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PHP Intelephense is still the foundation of PHP development in VS Code. It provides intelligent autocompletion, type inference, error detection, and navigation across large codebases.&lt;/p&gt;

&lt;p&gt;In real projects, it helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Catch undefined variables before runtime&lt;/li&gt;
&lt;li&gt;Jump between classes and methods instantly&lt;/li&gt;
&lt;li&gt;Understand function signatures without opening documentation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For most developers, VS Code without Intelephense does not feel complete.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. PHP CS Fixer
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code consistency becomes critical as projects grow and teams expand. PHP CS Fixer automatically formats your code based on standards like PSR-12.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"php-cs-fixer.enable"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"php-cs-fixer.enableAutoFixOnSave"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This removes formatting arguments from code reviews and keeps the entire codebase consistent.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. PHP Debug (Xdebug)
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Debugging with &lt;code&gt;dd()&lt;/code&gt; and logs only gets you so far. PHP Debug integrates Xdebug directly into VS Code, allowing you to set breakpoints and inspect variables while the code runs.&lt;/p&gt;

&lt;p&gt;Typical usage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Debug complex request flows&lt;/li&gt;
&lt;li&gt;Understand why a condition behaves unexpectedly&lt;/li&gt;
&lt;li&gt;Step through framework internals when needed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you get comfortable with Xdebug, debugging becomes far less stressful.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Laravel (Official)
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=laravel.vscode-laravel" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=laravel.vscode-laravel&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a major change compared to previous years. Laravel now maintains an &lt;strong&gt;official VS Code extension&lt;/strong&gt; that replaces multiple community extensions.&lt;/p&gt;

&lt;p&gt;It provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Route autocompletion&lt;/li&gt;
&lt;li&gt;Blade syntax support&lt;/li&gt;
&lt;li&gt;Laravel helper and facade suggestions&lt;/li&gt;
&lt;li&gt;Artisan command integration&lt;/li&gt;
&lt;li&gt;Improved Laravel project awareness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For Laravel developers in 2026, this single extension covers what used to require several separate tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Blade Snippets
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel-blade" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel-blade&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even with the official Laravel extension, Blade Snippets remains useful for faster template writing.&lt;/p&gt;

&lt;p&gt;It helps by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expanding Blade directives quickly&lt;/li&gt;
&lt;li&gt;Reducing repetitive typing&lt;/li&gt;
&lt;li&gt;Keeping view files clean and readable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It pairs well with the official Laravel extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Docker
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most modern PHP applications now run inside containers. The Docker extension allows you to manage containers directly from VS Code.&lt;/p&gt;

&lt;p&gt;With it, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start and stop services&lt;/li&gt;
&lt;li&gt;Inspect container logs&lt;/li&gt;
&lt;li&gt;Attach debuggers to running containers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This keeps your workflow inside the editor instead of jumping between terminals and tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. GitLens
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GitLens enhances the built-in Git features of VS Code and is invaluable in team environments.&lt;/p&gt;

&lt;p&gt;It helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;See who last modified a line&lt;/li&gt;
&lt;li&gt;Explore commit history per file&lt;/li&gt;
&lt;li&gt;Understand why changes were made&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This context is extremely useful during debugging and code reviews.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Code Runner
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code Runner is useful for quick experiments and testing small PHP scripts.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Quick test"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run this instantly without configuring a full project or server, which is great for learning and prototyping.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. EditorConfig for VS Code
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;EditorConfig ensures consistent coding styles across different editors and operating systems.&lt;/p&gt;

&lt;p&gt;It controls:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Indentation&lt;/li&gt;
&lt;li&gt;Line endings&lt;/li&gt;
&lt;li&gt;File encoding&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This becomes especially important when multiple developers work on the same project.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Thunder Client
&lt;/h2&gt;

&lt;p&gt;Link: &lt;a href="https://marketplace.visualstudio.com/items?itemName=rangav.vscode-thunder-client" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=rangav.vscode-thunder-client&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thunder Client is a modern replacement for older REST tools inside VS Code.&lt;/p&gt;

&lt;p&gt;It allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test APIs&lt;/li&gt;
&lt;li&gt;Send HTTP requests&lt;/li&gt;
&lt;li&gt;Save collections per project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For backend PHP developers working with APIs, this removes the need for external tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;In 2026, PHP development in VS Code is more useful than ever. Many older extensions are no longer needed, and official tooling has replaced fragmented solutions, especially in the Laravel ecosystem.&lt;/p&gt;

&lt;p&gt;By choosing a focused and up-to-date extension set, you reduce noise, avoid conflicts, and build a development environment that actually supports how modern PHP applications are built today.&lt;/p&gt;

&lt;p&gt;Start with the essentials, add what you truly need, and keep your editor lean. That alone can noticeably improve both productivity and code quality.&lt;/p&gt;

&lt;p&gt;What are your go-to VS Code extensions for php development? Share your recommendations in the comments below!&lt;/p&gt;

&lt;p&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/arafatweb" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/arafatweb&lt;/a&gt;&lt;br&gt;
Portfolio: &lt;a href="https://arafatdev.com/" rel="noopener noreferrer"&gt;https://arafatdev.com/&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/arafat-web" rel="noopener noreferrer"&gt;https://github.com/arafat-web&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>vscode</category>
      <category>php</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Pusher vs Socket.io Explained for Beginners</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Tue, 13 Jan 2026 10:06:14 +0000</pubDate>
      <link>https://dev.to/arafatweb/pusher-vs-socketio-explained-for-beginners-5d0p</link>
      <guid>https://dev.to/arafatweb/pusher-vs-socketio-explained-for-beginners-5d0p</guid>
      <description>&lt;p&gt;You have probably heard people say things like “just use WebSockets” or “Pusher is easier” when talking about real time features. At first, this topic usually feels confusing, boring, or overly technical, especially if you are still getting comfortable with backend development. In this post, I will break down Pusher vs Socket.io using simple language and real-world examples so you can clearly understand what each one does and when to use them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What problem are we trying to solve&lt;/li&gt;
&lt;li&gt;What is Pusher&lt;/li&gt;
&lt;li&gt;What is Socket.io&lt;/li&gt;
&lt;li&gt;A simple real-world analogy&lt;/li&gt;
&lt;li&gt;Setup and development experience&lt;/li&gt;
&lt;li&gt;Control and flexibility&lt;/li&gt;
&lt;li&gt;Scaling and infrastructure&lt;/li&gt;
&lt;li&gt;Code examples side by side&lt;/li&gt;
&lt;li&gt;Common mistakes beginners make&lt;/li&gt;
&lt;li&gt;When should you choose which&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What problem are we trying to solve
&lt;/h2&gt;

&lt;p&gt;Both Pusher and Socket.io exist to solve the same core problem.&lt;/p&gt;

&lt;p&gt;How do you send data from the server to the browser instantly without the browser asking for it every few seconds?&lt;/p&gt;

&lt;p&gt;Examples of this problem include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chat messages appearing instantly&lt;/li&gt;
&lt;li&gt;Notifications updating in real time&lt;/li&gt;
&lt;li&gt;Live dashboards&lt;/li&gt;
&lt;li&gt;Online collaboration features&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without WebSockets or similar tools, you would rely on polling, which is inefficient and slow.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Pusher
&lt;/h2&gt;

&lt;p&gt;Pusher is a hosted real time messaging service.&lt;/p&gt;

&lt;p&gt;You do not run WebSocket servers yourself. Pusher gives you an API and infrastructure that handles connections, scaling, and message delivery.&lt;/p&gt;

&lt;p&gt;You mainly focus on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sending events from your backend&lt;/li&gt;
&lt;li&gt;Listening for events on the frontend&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You do not worry much about servers, load balancing, or connection management.&lt;/p&gt;

&lt;p&gt;Key characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Managed service&lt;/li&gt;
&lt;li&gt;Very fast to set up&lt;/li&gt;
&lt;li&gt;Paid after a small free tier&lt;/li&gt;
&lt;li&gt;Less control over low-level behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Socket.io
&lt;/h2&gt;

&lt;p&gt;Socket. IO is a JavaScript library that helps you build real time applications using WebSockets.&lt;/p&gt;

&lt;p&gt;Unlike Pusher, you host and manage the server yourself.&lt;/p&gt;

&lt;p&gt;You are responsible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Running the WebSocket server&lt;/li&gt;
&lt;li&gt;Scaling it&lt;/li&gt;
&lt;li&gt;Handling reconnects and edge cases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Key characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open source&lt;/li&gt;
&lt;li&gt;Full control&lt;/li&gt;
&lt;li&gt;No service cost, but infrastructure cost&lt;/li&gt;
&lt;li&gt;More setup and maintenance&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A simple real-world analogy
&lt;/h2&gt;

&lt;p&gt;Think of a restaurant.&lt;/p&gt;

&lt;p&gt;Using Pusher is like hiring a food delivery service.&lt;/p&gt;

&lt;p&gt;You prepare the food and hand it over, and the delivery company takes care of drivers, routes, and timing. You pay for the service, but your workload is smaller.&lt;/p&gt;

&lt;p&gt;Using Socket.io is like running your own delivery fleet.&lt;/p&gt;

&lt;p&gt;You hire drivers, manage vehicles, plan routes, and deal with breakdowns. You have full control but also full responsibility.&lt;/p&gt;

&lt;p&gt;Neither approach is wrong. They serve different needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup and development experience
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pusher setup
&lt;/h3&gt;

&lt;p&gt;Pusher setup is usually quick.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create an account&lt;/li&gt;
&lt;li&gt;Get app keys&lt;/li&gt;
&lt;li&gt;Install a backend SDK&lt;/li&gt;
&lt;li&gt;Install a frontend SDK&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can often send your first real time event in under an hour.&lt;/p&gt;

&lt;p&gt;This is especially friendly for beginners or small teams.&lt;/p&gt;

&lt;h3&gt;
  
  
  Socket.io setup
&lt;/h3&gt;

&lt;p&gt;Socket.io requires more steps.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a Node.js server&lt;/li&gt;
&lt;li&gt;Configure Socket.io&lt;/li&gt;
&lt;li&gt;Manage connections&lt;/li&gt;
&lt;li&gt;Think about scaling early&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not bad, but it is more work, especially if your main backend is PHP or Laravel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Control and flexibility
&lt;/h2&gt;

&lt;p&gt;This is where Socket.io shines.&lt;/p&gt;

&lt;p&gt;With Socket.io, you control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authentication logic&lt;/li&gt;
&lt;li&gt;Custom events&lt;/li&gt;
&lt;li&gt;Room management&lt;/li&gt;
&lt;li&gt;Message routing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With Pusher, you work within their system.&lt;/p&gt;

&lt;p&gt;You trade flexibility for simplicity.&lt;/p&gt;

&lt;p&gt;If you need deep customization, Socket.io usually wins.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scaling and infrastructure
&lt;/h2&gt;

&lt;p&gt;Scaling is the biggest difference.&lt;/p&gt;

&lt;p&gt;Pusher handles scaling for you. If traffic spikes, your app usually keeps working.&lt;/p&gt;

&lt;p&gt;With Socket.io, scaling means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple servers&lt;/li&gt;
&lt;li&gt;Shared state&lt;/li&gt;
&lt;li&gt;Redis or similar tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is doable, but not beginner-friendly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code examples side by side
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Sending an event with Pusher in PHP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$pusher&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'chat-channel'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'new-message'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'user'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Alice'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'message'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Hello world'&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does:&lt;br&gt;
It sends a real time event called &lt;code&gt;new-message&lt;/code&gt; to everyone listening on &lt;code&gt;chat-channel&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Why it matters:&lt;br&gt;
You do not manage connections yourself.&lt;/p&gt;

&lt;p&gt;When to use it:&lt;br&gt;
Simple real time features with minimal setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sending a message with Socket.io
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;io&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;connection&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;send-message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;io&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;emit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;new-message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does:&lt;br&gt;
It listens for a message and broadcasts it to all connected clients.&lt;/p&gt;

&lt;p&gt;Why it matters:&lt;br&gt;
You fully control how messages flow.&lt;/p&gt;

&lt;p&gt;When to use it:&lt;br&gt;
Complex real time systems that need customization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes beginners make
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Choosing Socket.io without understanding scaling&lt;/li&gt;
&lt;li&gt;Using Pusher for extremely custom workflows&lt;/li&gt;
&lt;li&gt;Mixing real-time tools without a clear plan&lt;/li&gt;
&lt;li&gt;Ignoring security and authentication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start simple. Complexity can always be added later.&lt;/p&gt;

&lt;h2&gt;
  
  
  When should you choose which
&lt;/h2&gt;

&lt;p&gt;Choose Pusher if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want speed and simplicity&lt;/li&gt;
&lt;li&gt;You are new to real-time systems&lt;/li&gt;
&lt;li&gt;You do not want to manage infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choose Socket.io if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need full control&lt;/li&gt;
&lt;li&gt;You are comfortable managing servers&lt;/li&gt;
&lt;li&gt;You expect complex real-time logic&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Most beginners think the choice is about which tool is better. In reality, it is about responsibility.&lt;/p&gt;

&lt;p&gt;Pushers remove responsibility in exchange for cost and limits. Socket.io gives you power in exchange for maintenance and complexity.&lt;/p&gt;

&lt;p&gt;If you are still learning backend development, starting with Pusher is often a calmer and safer path. Once you understand real-time concepts well, Socket.io starts to make a lot more sense.&lt;/p&gt;

&lt;p&gt;Take the path that reduces friction for your current stage, not the one that sounds more impressive.&lt;/p&gt;

</description>
      <category>socket</category>
      <category>backend</category>
      <category>pusher</category>
      <category>realtime</category>
    </item>
    <item>
      <title>Understanding the Laravel Lifecycle (Explained for Beginners)</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Sun, 05 Oct 2025 07:21:21 +0000</pubDate>
      <link>https://dev.to/arafatweb/understanding-the-laravel-lifecycle-explained-for-beginners-dc6</link>
      <guid>https://dev.to/arafatweb/understanding-the-laravel-lifecycle-explained-for-beginners-dc6</guid>
      <description>&lt;p&gt;The &lt;strong&gt;Laravel Lifecycle&lt;/strong&gt; is one of the most asked interview questions for junior developers and for good reason.&lt;/p&gt;

&lt;p&gt;At first, it may sound complex, but once you understand how it works, you’ll find it surprisingly elegant and even exciting.&lt;/p&gt;

&lt;p&gt;Let’s break it down in simple words and real-world examples.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Table of Contents&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What Is the Laravel Lifecycle?&lt;/li&gt;
&lt;li&gt;Step-by-Step Breakdown&lt;/li&gt;
&lt;li&gt;Real-World Analogy&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;1. What Is the Laravel Lifecycle?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In short, the &lt;strong&gt;Laravel Lifecycle&lt;/strong&gt; is the full journey of a user’s request from the moment it enters your application until the response is sent back to the browser.&lt;/p&gt;

&lt;p&gt;Think of it like ordering food at a restaurant:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You (the user) make a &lt;strong&gt;request&lt;/strong&gt; (place an order).&lt;/li&gt;
&lt;li&gt;The kitchen (Laravel) processes your order.&lt;/li&gt;
&lt;li&gt;You get your &lt;strong&gt;response&lt;/strong&gt; (the dish served).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s exactly what Laravel does it receives a request, processes it through multiple layers, and returns a response.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;2. Step-by-Step Breakdown&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s go through each step that happens behind the scenes when you load a Laravel page.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 1: The Entry Point – &lt;code&gt;public/index.php&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Every request starts at &lt;strong&gt;&lt;code&gt;public/index.php&lt;/code&gt;&lt;/strong&gt;, which is Laravel’s &lt;strong&gt;entry point&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It’s like the &lt;strong&gt;main gate&lt;/strong&gt; of a building no matter where you come from, everyone enters through it.&lt;/p&gt;

&lt;p&gt;From here, Laravel starts bootstrapping (preparing) the application.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2: The Bootstrap Process – &lt;code&gt;bootstrap/app.php&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;After entering &lt;code&gt;index.php&lt;/code&gt;, the request moves to &lt;strong&gt;&lt;code&gt;bootstrap/app.php&lt;/code&gt;&lt;/strong&gt;, where Laravel’s &lt;strong&gt;Application Instance&lt;/strong&gt; is created.&lt;/p&gt;

&lt;p&gt;You can think of this as Laravel “waking up” it sets up everything it needs to handle the request.&lt;/p&gt;

&lt;p&gt;At this point, Laravel loads the &lt;strong&gt;Kernel&lt;/strong&gt;, which acts like the “traffic manager” of the application.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 3: Service Providers Load&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Next, Laravel loads all &lt;strong&gt;Service Providers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;These are the &lt;strong&gt;core building blocks&lt;/strong&gt; that boot up features like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Database connections&lt;/li&gt;
&lt;li&gt;Event handling&lt;/li&gt;
&lt;li&gt;Routing&lt;/li&gt;
&lt;li&gt;Caching&lt;/li&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s like a car starting its systems the engine, AC, lights, and brakes all come online before you start driving.&lt;/p&gt;

&lt;p&gt;You can find all service providers in &lt;code&gt;config/app.php&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 4: Middleware Runs&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Before the request reaches your controller, Laravel passes it through &lt;strong&gt;Middleware&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Middleware are like &lt;strong&gt;security gates&lt;/strong&gt; they check and filter requests.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Checking if the user is logged in (&lt;code&gt;Auth&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Protecting against CSRF attacks&lt;/li&gt;
&lt;li&gt;Managing sessions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If any middleware fails (e.g., user not logged in), Laravel stops the request right there and returns a proper response (like redirecting to a login page).&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 5: Routing and Controllers&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once the request passes through middleware, &lt;strong&gt;Laravel’s routing system&lt;/strong&gt; decides &lt;strong&gt;where to send it&lt;/strong&gt;.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/user/profile'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;UserController&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'show'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s what happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Laravel checks if the route &lt;code&gt;/user/profile&lt;/code&gt; exists.&lt;/li&gt;
&lt;li&gt;It finds that it should call the &lt;code&gt;show()&lt;/code&gt; method of &lt;code&gt;UserController&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Laravel executes that controller method.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can think of the route as a &lt;strong&gt;GPS&lt;/strong&gt; that directs your request to the correct location.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 6: Models, Database, and Response&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Inside the controller, Laravel may use &lt;strong&gt;Models&lt;/strong&gt; to interact with the &lt;strong&gt;Database&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'profile'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'user'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s what happens behind the scenes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The controller asks the Model (&lt;code&gt;User&lt;/code&gt;) to fetch data from the database.&lt;/li&gt;
&lt;li&gt;The database returns the result.&lt;/li&gt;
&lt;li&gt;The controller sends that data to a &lt;strong&gt;view file&lt;/strong&gt; (Blade template).&lt;/li&gt;
&lt;li&gt;Laravel converts the view into an &lt;strong&gt;HTML response&lt;/strong&gt; and sends it back to the browser.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In short:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Controller → Model → Database → Controller → View → Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;3. Real-World Analogy&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine Laravel as a &lt;strong&gt;restaurant&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Laravel Component&lt;/th&gt;
&lt;th&gt;Restaurant Equivalent&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;code&gt;index.php&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Main entrance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app.php&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Kitchen setup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Service Providers&lt;/td&gt;
&lt;td&gt;Staff preparing tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Middleware&lt;/td&gt;
&lt;td&gt;Security checking tickets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Routing&lt;/td&gt;
&lt;td&gt;Waiter taking your order to the right chef&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Controller &amp;amp; Model&lt;/td&gt;
&lt;td&gt;Chef preparing the meal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Response&lt;/td&gt;
&lt;td&gt;Meal served to your table&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;By the time your meal (response) reaches you, Laravel has handled dozens of internal tasks but it all happens in milliseconds!&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;4. Final Thoughts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The Laravel Lifecycle might look complex at first, but once you understand the flow, it becomes one of the most fascinating parts of the framework.&lt;/p&gt;

&lt;p&gt;Understanding this process helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Debug your application more effectively.&lt;/li&gt;
&lt;li&gt;Write optimized and organized code.&lt;/li&gt;
&lt;li&gt;Appreciate how Laravel handles so much for you behind the scenes.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Quick Recap of the Flow&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Entry (index.php)
→ bootstrap/app.php
→ Kernel
→ Service Providers
→ Middleware
→ Routing
→ Controller
→ Model
→ Database
→ Controller
→ View/Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Laravel makes this entire process feel seamless transforming a simple user request into a powerful, structured response in just a fraction of a second.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>architecture</category>
      <category>laravel</category>
      <category>php</category>
    </item>
    <item>
      <title>Top 10 VS Code Extensions for Laravel Developers in 2025</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Mon, 29 Sep 2025 13:20:13 +0000</pubDate>
      <link>https://dev.to/arafatweb/top-10-vs-code-extensions-for-laravel-developers-in-2025-1np5</link>
      <guid>https://dev.to/arafatweb/top-10-vs-code-extensions-for-laravel-developers-in-2025-1np5</guid>
      <description>&lt;p&gt;Hey everyone,&lt;/p&gt;

&lt;p&gt;Let's talk about our primary tool: the code editor. A fresh install of VS Code is great, but if you're serious about Laravel development, you're leaving a ton of productivity on the table without the right extensions. The right setup can automate the boring stuff, catch errors, and make your entire workflow feel smoother.&lt;/p&gt;

&lt;p&gt;After years of tweaking my own environment, I've narrowed it down to a core set of tools that I use on every single project. These are the extensions that genuinely make a difference in my day-to-day.&lt;/p&gt;

&lt;p&gt;Here is my definitive list of the 10 must-have VS Code extensions for any Laravel developer in 2025.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; Laravel - The Official Extension
&lt;/li&gt;
&lt;li&gt; Laravel Blade Snippets
&lt;/li&gt;
&lt;li&gt; Laravel Extra Intellisense
&lt;/li&gt;
&lt;li&gt; Laravel Goto View
&lt;/li&gt;
&lt;li&gt; PHP Intelephense
&lt;/li&gt;
&lt;li&gt; Laravel Pint
&lt;/li&gt;
&lt;li&gt; PHP Debug
&lt;/li&gt;
&lt;li&gt; REST Client
&lt;/li&gt;
&lt;li&gt; Prettier - Code Formatter
&lt;/li&gt;
&lt;li&gt;GitLens&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  1. Laravel - The Official Extension
&lt;/h3&gt;

&lt;p&gt;This is the big one, often overlooked because it's so awesome. It includes everything from Artisan commands right in your command palette to route and view navigation, validation rules completion, and even environment variable management. It's truly an all-in-one powerhouse that streamlines so many daily tasks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; A comprehensive toolkit that brings many Laravel-specific functionalities directly into VS Code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=laravel.vscode-laravel" rel="noopener noreferrer"&gt;Laravel on Marketplace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Laravel Blade Snippets
&lt;/h3&gt;

&lt;p&gt;Even with the main Laravel extension, this focused extension for Blade is incredibly valuable. It adds robust syntax highlighting and a massive collection of snippets for Blade directives, conditionals, and loops. Typing &lt;code&gt;b:foreach&lt;/code&gt; and hitting tab to get the full structure for a loop is a small thing that saves a ton of time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; Drastically speeds up the creation and editing of your Blade templates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel-blade" rel="noopener noreferrer"&gt;Laravel Blade Snippets on Marketplace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Laravel Extra Intellisense
&lt;/h3&gt;

&lt;p&gt;This is your go-to for making VS Code truly understand your Laravel project's internal workings. It provides intelligent autocompletion for route names, views, config values, and even validation rules. No more guessing route names or constantly flipping between files. It just works.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; Boosts coding speed and accuracy by providing smart, context-aware autocompletion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=amiralizadeh9480.laravel-extra-intellisense" rel="noopener noreferrer"&gt;Laravel Extra Intellisense on Marketplace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Laravel Goto View
&lt;/h3&gt;

&lt;p&gt;Jumping between your controllers and their corresponding views can be a hassle. This extension makes it trivial. Simply &lt;code&gt;Ctrl+Click&lt;/code&gt; (or &lt;code&gt;Cmd+Click&lt;/code&gt; on Mac) on a view name in your controller, and you're instantly transported to that Blade file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In your controller...&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Post&lt;/span&gt; &lt;span class="nv"&gt;$post&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Ctrl+Clicking on 'posts.show' takes you directly to the view file.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'posts.show'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;compact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'post'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; Provides seamless navigation between your PHP logic and your Blade templates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=codingyu.laravel-goto-view" rel="noopener noreferrer"&gt;Laravel Goto View on Marketplace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. PHP Intelephense
&lt;/h3&gt;

&lt;p&gt;While not Laravel-specific, this is the absolute foundation for any PHP development in VS Code. It offers incredibly fast code completion, signature help, go-to-definition, and detailed diagnostics. It's the engine that powers most of the "smart" features you expect from an IDE for PHP code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; Transforms VS Code into a robust, high-performance PHP IDE.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client" rel="noopener noreferrer"&gt;PHP Intelephense on Marketplace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Laravel Pint
&lt;/h3&gt;

&lt;p&gt;Code consistency is key for maintainable projects and smooth team collaboration. Laravel Pint is the official, zero-configuration PHP code style fixer. This extension integrates Pint directly into VS Code, automatically formatting your PHP files on save according to Laravel's coding standards.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; Automates code formatting, ensuring a clean and consistent style across your PHP codebase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=open-southeners.laravel-pint" rel="noopener noreferrer"&gt;Laravel Pint on Marketplace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. PHP Debug
&lt;/h3&gt;

&lt;p&gt;Stop relying solely on &lt;code&gt;dd()&lt;/code&gt; for debugging. Learning to use a proper step-debugger is a huge leap in productivity. This extension integrates Xdebug, allowing you to set breakpoints, inspect variables, and step through your code line-by-line. It's invaluable for tracking down complex bugs efficiently.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; Provides professional-grade debugging capabilities directly within your editor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug" rel="noopener noreferrer"&gt;PHP Debug on Marketplace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. REST Client
&lt;/h3&gt;

&lt;p&gt;Many Laravel projects involve building and consuming APIs. This extension allows you to send HTTP requests and view the responses directly within VS Code, eliminating the need to switch to external tools like Postman for quick testing. You define your requests in a &lt;code&gt;.http&lt;/code&gt; file with a straightforward syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;### Get all users from the API
GET http://my-app.test/api/users
Accept: application/json
Authorization: Bearer YOUR_API_TOKEN

###
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; Streamlines API testing by keeping it within your development environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=humao.rest-client" rel="noopener noreferrer"&gt;REST Client on Marketplace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  9. Prettier - Code Formatter
&lt;/h3&gt;

&lt;p&gt;While Laravel Pint keeps your PHP tidy, Prettier handles everything else. It's an opinionated code formatter for JavaScript, CSS, JSON, Markdown, and more. It ensures a consistent and clean style across all your front-end assets, making your entire project visually cohesive.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; Ensures consistent code formatting across all non-PHP files in your project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode" rel="noopener noreferrer"&gt;Prettier - Code Formatter&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  10. GitLens
&lt;/h3&gt;

&lt;p&gt;This extension significantly enhances VS Code's built-in Git capabilities. GitLens provides invaluable features like inline blame annotations (showing who changed what line and when), a powerful history view, and easy comparison tools. It's crucial for understanding codebase evolution and collaborating effectively.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why it's essential:&lt;/strong&gt; Offers deep insights into your Git repository history directly within your editor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grab it here:&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens" rel="noopener noreferrer"&gt;GitLens on Marketplace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  FAQs
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q: Do I need to install all of these?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;A:&lt;/strong&gt; Not necessarily. This is a comprehensive list, but you should prioritize extensions that address your biggest pain points. Start with the main "Laravel" extension and PHP Intelephense, then add others as needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: Are these extensions free?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;A:&lt;/strong&gt; Yes, all extensions mentioned are free to use. Some might offer premium tiers for advanced features, but their free versions provide substantial benefits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: Will these extensions slow down my VS Code?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;A:&lt;/strong&gt; While having many extensions &lt;em&gt;can&lt;/em&gt; theoretically impact performance, those listed here are generally well-optimized. VS Code also includes tools to monitor extension performance. It's good practice to disable any extensions you don't actively use.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Equipping your VS Code with the right extensions is one of the quickest ways to boost your productivity as a Laravel developer. By using these tools, you can streamline common tasks, ensure code quality, and make your development experience much more efficient and enjoyable.&lt;/p&gt;

&lt;p&gt;What are your go-to VS Code extensions for Laravel development? Share your recommendations in the comments below!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LinkedIn:&lt;/strong&gt; &lt;a href="https://www.google.com/search?q=https://www.linkedin.com/in/arafatweb" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/arafatweb&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portfolio:&lt;/strong&gt; &lt;a href="https://arafatdev.com/" rel="noopener noreferrer"&gt;https://arafatdev.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/arafat-web" rel="noopener noreferrer"&gt;https://github.com/arafat-web&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>laravel</category>
      <category>vscode</category>
      <category>php</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Bulk Email Sender v2.0: From Simple Tool to Professional Email Marketing Platform</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Sat, 26 Jul 2025 08:33:34 +0000</pubDate>
      <link>https://dev.to/arafatweb/bulk-email-sender-v20-from-simple-tool-to-professional-email-marketing-platform-29dm</link>
      <guid>https://dev.to/arafatweb/bulk-email-sender-v20-from-simple-tool-to-professional-email-marketing-platform-29dm</guid>
      <description>&lt;p&gt;Hey dev community! 👋 &lt;/p&gt;

&lt;p&gt;Remember that bulk email sender I built with Laravel a while back? Well, it's gotten a MASSIVE upgrade! What started as a simple tool for sending bulk emails has evolved into a full-fledged email marketing platform. Let me walk you through everything that's new in v2.0!&lt;/p&gt;

&lt;h2&gt;
  
  
  What Was Missing in v1.0?
&lt;/h2&gt;

&lt;p&gt;Don't get me wrong - v1.0 did its job. You could send bulk emails, and that was pretty much it. But after using it for a while (and getting feedback from the community), I realized it was missing some crucial features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No proper contact management&lt;/li&gt;
&lt;li&gt;Couldn't send individual emails&lt;/li&gt;
&lt;li&gt;No way to organize contacts&lt;/li&gt;
&lt;li&gt;Basic UI that looked... well, basic&lt;/li&gt;
&lt;li&gt;No proper queue system for large campaigns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sound familiar? Yeah, I know. It was more of a "quick hack" than a professional tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's New in v2.0? (Spoiler: A LOT!)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Complete Contact Management System
&lt;/h3&gt;

&lt;p&gt;This was the big one! Now you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add contacts individually or in bulk&lt;/li&gt;
&lt;li&gt;Import from CSV/Excel files (with proper validation!)&lt;/li&gt;
&lt;li&gt;View all contacts in a clean, paginated table&lt;/li&gt;
&lt;li&gt;Edit and delete contacts easily&lt;/li&gt;
&lt;li&gt;Export your contact lists&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvyt9exn63yjhooz8u7a7.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%2Fvyt9exn63yjhooz8u7a7.png" alt="Contact Management" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Smart Tag System
&lt;/h3&gt;

&lt;p&gt;Want to send emails to just your VIP customers? Or maybe only to people from a specific city? Tags got you covered!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create custom tags (VIP, City-NYC, Newsletter-Subscribers, etc.)&lt;/li&gt;
&lt;li&gt;Assign multiple tags to contacts&lt;/li&gt;
&lt;li&gt;Send targeted campaigns to specific tags&lt;/li&gt;
&lt;li&gt;Filter contacts by tags&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqltzgbmd1gzwnyf2lnw8.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%2Fqltzgbmd1gzwnyf2lnw8.png" alt="Tag Management" width="800" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Individual Email Feature
&lt;/h3&gt;

&lt;p&gt;Sometimes you don't want to send to everyone. Now you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Send personalized emails to specific contacts&lt;/li&gt;
&lt;li&gt;Use the same rich text editor&lt;/li&gt;
&lt;li&gt;Perfect for follow-ups or personal messages&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk7i9p0aul07lx454z6wr.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%2Fk7i9p0aul07lx454z6wr.png" alt="Individual Emails" width="800" height="1010"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Modern UI Overhaul
&lt;/h3&gt;

&lt;p&gt;Let's be honest - v1.0 looked like it was built in 2010. v2.0 brings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clean, modern Bootstrap 5 design&lt;/li&gt;
&lt;li&gt;Responsive layout that works on mobile&lt;/li&gt;
&lt;li&gt;Proper navigation with breadcrumbs&lt;/li&gt;
&lt;li&gt;Dark mode support (because why not?)&lt;/li&gt;
&lt;li&gt;Professional sidebar navigation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1uaxhlnnocmk54mgy4dv.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%2F1uaxhlnnocmk54mgy4dv.png" alt="Dashboard" width="800" height="1155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Excel Import/Export
&lt;/h3&gt;

&lt;p&gt;This one was a game-changer for productivity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Import contacts from CSV/Excel files&lt;/li&gt;
&lt;li&gt;Proper validation and error handling&lt;/li&gt;
&lt;li&gt;Export your contacts for backup&lt;/li&gt;
&lt;li&gt;Sample CSV template provided&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. 🔧 Queue System Integration
&lt;/h3&gt;

&lt;p&gt;No more waiting around for large campaigns! Now using Laravel Queues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Background email processing&lt;/li&gt;
&lt;li&gt;No timeouts on large campaigns&lt;/li&gt;
&lt;li&gt;Better server resource management&lt;/li&gt;
&lt;li&gt;Real-time progress tracking&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Technical Improvements
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Code Quality
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Proper MVC architecture&lt;/li&gt;
&lt;li&gt;Form validation with Laravel's built-in validators&lt;/li&gt;
&lt;li&gt;Database relationships and migrations&lt;/li&gt;
&lt;li&gt;Queue jobs for email processing&lt;/li&gt;
&lt;li&gt;Error handling and logging&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Performance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Paginated contact lists&lt;/li&gt;
&lt;li&gt;Optimized database queries&lt;/li&gt;
&lt;li&gt;Asset optimization with Vite&lt;/li&gt;
&lt;li&gt;Proper caching strategies&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Security
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;CSRF protection on all forms&lt;/li&gt;
&lt;li&gt;Input sanitization&lt;/li&gt;
&lt;li&gt;SQL injection prevention&lt;/li&gt;
&lt;li&gt;Secure file uploads&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation &amp;amp; Setup (It's Still Super Easy!)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Clone the repository&lt;/span&gt;
git clone https://github.com/arafat-web/Bulk-Email-Sender.git
&lt;span class="nb"&gt;cd &lt;/span&gt;Bulk-Email-Sender

&lt;span class="c"&gt;# Install dependencies&lt;/span&gt;
composer &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# Setup environment&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
php artisan key:generate

&lt;span class="c"&gt;# Setup database&lt;/span&gt;
php artisan migrate &lt;span class="nt"&gt;--seed&lt;/span&gt;

&lt;span class="c"&gt;# Start the application&lt;/span&gt;
php artisan serve
php artisan queue:work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Default login:&lt;/strong&gt; &lt;code&gt;admin@email.com&lt;/code&gt; / &lt;code&gt;12345678&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Use Cases
&lt;/h2&gt;

&lt;p&gt;Since launching v2.0, I've seen people use it for:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Newsletter Management&lt;/strong&gt; - Import subscribers, organize by interests with tags&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Event Invitations&lt;/strong&gt; - Send bulk invites, then individual follow-ups&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customer Support&lt;/strong&gt; - Organize customers by product, send targeted updates&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Marketing Campaigns&lt;/strong&gt; - Segment audiences with tags, track engagement&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community Management&lt;/strong&gt; - Organize members, send announcements&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What I Learned Building This
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. User Feedback is Gold
&lt;/h3&gt;

&lt;p&gt;The v1.0 feedback taught me that users needed more than just "send email to everyone." They needed organization, targeting, and flexibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. UI/UX Matters More Than I Thought
&lt;/h3&gt;

&lt;p&gt;A clean interface isn't just pretty - it actually makes the tool more efficient to use. Who knew? 😅&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Laravel Queues Are Amazing
&lt;/h3&gt;

&lt;p&gt;Seriously, if you're not using queues for heavy tasks, you're missing out. Game-changer for user experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Progressive Enhancement Works
&lt;/h3&gt;

&lt;p&gt;Started simple with v1.0, then added features based on actual needs. Much better than trying to build everything upfront.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;I'm already thinking about v3.0! Some ideas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email templates management&lt;/li&gt;
&lt;li&gt;A/B testing for campaigns&lt;/li&gt;
&lt;li&gt;Analytics and reporting&lt;/li&gt;
&lt;li&gt;API for integrations&lt;/li&gt;
&lt;li&gt;Multi-user support&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Want to Contribute?
&lt;/h2&gt;

&lt;p&gt;The project is completely open source! Whether you want to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Report bugs&lt;/li&gt;
&lt;li&gt;Suggest features&lt;/li&gt;
&lt;li&gt;Submit pull requests&lt;/li&gt;
&lt;li&gt;Improve documentation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything is welcome! Check out the &lt;a href="https://github.com/arafat-web/Bulk-Email-Sender" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Screenshots Gallery
&lt;/h2&gt;

&lt;p&gt;Here are some more screenshots showing the features in action:&lt;/p&gt;

&lt;h3&gt;
  
  
  Email Templates
&lt;/h3&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%2F40la7agarxc85naxdxgj.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%2F40la7agarxc85naxdxgj.png" alt="Email Templates" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Instant Campaign
&lt;/h3&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%2Fy1b2tsjt7ujbf5xhomt5.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%2Fy1b2tsjt7ujbf5xhomt5.png" alt="Instant Campaign" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Email Accounts Settings
&lt;/h3&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%2Fd3j8jch558vqgwkq2iuu.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%2Fd3j8jch558vqgwkq2iuu.png" alt="Email Accounts" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎉 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Building v2.0 has been an incredible journey. What started as a simple weekend project has become something I'm genuinely proud of. The Laravel community's feedback and support made this possible.&lt;/p&gt;

&lt;p&gt;If you're working on email marketing, managing newsletters, or just need to send bulk emails occasionally, give it a try! And if you find it useful, a ⭐ on GitHub would make my day!&lt;/p&gt;

&lt;h2&gt;
  
  
  🔗 Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;a href="https://github.com/arafat-web/Bulk-Email-Sender" rel="noopener noreferrer"&gt;arafat-web/Bulk-Email-Sender&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live Demo&lt;/strong&gt;: &lt;a href="https://arafat-web.github.io/Bulk-Email-Sender/" rel="noopener noreferrer"&gt;GitHub Pages&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;My Website&lt;/strong&gt;: &lt;a href="https://arafatdev.com" rel="noopener noreferrer"&gt;arafatdev.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;What do you think about v2.0? Have you built similar tools? I'd love to hear your thoughts and experiences in the comments below! 👇&lt;/em&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>opensource</category>
      <category>marketing</category>
    </item>
    <item>
      <title>Design Your Database with dbdiagram.io (Beginner to Pro)</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Thu, 26 Jun 2025 14:29:43 +0000</pubDate>
      <link>https://dev.to/arafatweb/design-your-database-with-dbdiagramio-beginner-to-pro-20j6</link>
      <guid>https://dev.to/arafatweb/design-your-database-with-dbdiagramio-beginner-to-pro-20j6</guid>
      <description>&lt;p&gt;Designing a database schema can either be a quick sketch or a total nightmare, especially if you're working on a big project or collaborating with a team. But what if you could &lt;strong&gt;visually plan, share, and even generate your database schema&lt;/strong&gt; with just a few lines of easy-to-write code?&lt;/p&gt;

&lt;p&gt;That’s exactly what &lt;strong&gt;&lt;a href="https://dbdiagram.io" rel="noopener noreferrer"&gt;dbdiagram.io&lt;/a&gt;&lt;/strong&gt; helps you do. Whether you're a backend developer, a full-stack dev, or a database enthusiast, this tool will &lt;strong&gt;make your life 10x easier&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;What is dbdiagram.io?&lt;/li&gt;
&lt;li&gt;Why Use dbdiagram.io?&lt;/li&gt;
&lt;li&gt;Supported Syntax &amp;amp; Importing From Tools&lt;/li&gt;
&lt;li&gt;Let’s Design a Real Example – Blog System Schema&lt;/li&gt;
&lt;li&gt;Exporting SQL Scripts&lt;/li&gt;
&lt;li&gt;Collaboration &amp;amp; Sharing&lt;/li&gt;
&lt;li&gt;Tips for Better Schema Design&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  What is dbdiagram.io?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;dbdiagram.io&lt;/strong&gt; is a free, online database design tool where you can create database diagrams using a simple DSL (domain-specific language) or by importing your schema directly.&lt;/p&gt;

&lt;p&gt;No need to install clunky software or memorize ER diagram notations — just focus on &lt;strong&gt;what your data should look like&lt;/strong&gt;, and the tool takes care of the visualization.&lt;/p&gt;




&lt;h3&gt;
  
  
  Why Use dbdiagram.io?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Easy to use&lt;/strong&gt;: Just write schema like you're writing a config file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fast prototyping&lt;/strong&gt;: Great for startups, side-projects, or freelance gigs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visually shareable&lt;/strong&gt;: Auto-generates ER diagrams that you can share via links.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supports real DBs&lt;/strong&gt;: PostgreSQL, MySQL, SQL Server, Oracle, and more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free for individuals and small teams&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Supported Syntax &amp;amp; Importing From Tools
&lt;/h3&gt;

&lt;p&gt;You can use either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;dbml (Database Markup Language)&lt;/strong&gt; – dbdiagram’s native, super readable DSL&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SQL (MySQL/PostgreSQL)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Import from tools&lt;/strong&gt; like MySQL Workbench, PostgreSQL, Prisma, or Rails.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Let’s Design a Real Example – Blog System Schema
&lt;/h3&gt;

&lt;p&gt;Here's a real-world example of designing a database schema for a blogging platform using &lt;strong&gt;dbml&lt;/strong&gt; syntax.&lt;/p&gt;

&lt;h4&gt;
  
  
  ER Diagram DSL
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Table users {
  id int [pk, increment]
  name varchar
  email varchar
  password varchar
  created_at datetime
  updated_at datetime
}

Table profiles {
  id int [pk, increment]
  user_id int [ref: &amp;gt; users.id]
  bio text
  avatar_url varchar
  created_at datetime
  updated_at datetime
}

Table posts {
  id int [pk, increment]
  user_id int [ref: &amp;gt; users.id]
  title varchar
  content text
  created_at datetime
  updated_at datetime
}

Table comments {
  id int [pk, increment]
  post_id int [ref: &amp;gt; posts.id]
  user_id int [ref: &amp;gt; users.id]
  content text
  created_at datetime
  updated_at datetime
}

Table categories {
  id int [pk, increment]
  name varchar
  created_at datetime
  updated_at datetime
}

Table post_categories {
  post_id int [ref: &amp;gt; posts.id]
  category_id int [ref: &amp;gt; categories.id]
  created_at datetime
  updated_at datetime
  Note: 'Composite Primary Key'
  indexes {
    (post_id, category_id) [pk]
  }
}

Table tags {
  id int [pk, increment]
  name varchar
  created_at datetime
  updated_at datetime
}

Table post_tags {
  post_id int [ref: &amp;gt; posts.id]
  tag_id int [ref: &amp;gt; tags.id]
  created_at datetime
  updated_at datetime
  Note: 'Composite Primary Key'
  indexes {
    (post_id, tag_id) [pk]
  }
}

Table likes {
  id int [pk, increment]
  post_id int [ref: &amp;gt; posts.id]
  user_id int [ref: &amp;gt; users.id]
  created_at datetime
  updated_at datetime
  indexes {
    (post_id, user_id) [unique]
  }
}

Table followers {
  follower_id int [ref: &amp;gt; users.id]
  following_id int [ref: &amp;gt; users.id]
  created_at datetime
  Note: 'User following relationship'
  indexes {
    (follower_id, following_id) [pk]
  }
}

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

&lt;/div&gt;



&lt;p&gt;Paste this into &lt;a href="https://dbdiagram.io/d" rel="noopener noreferrer"&gt;https://dbdiagram.io/d&lt;/a&gt;, and you’ll instantly see a fully functional, visual representation of a blogging platform’s database (below image). No clicking, dragging, or aligning just clean, readable code.&lt;/p&gt;

&lt;h2&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%2F2bsm5jbgfwsefp7zdky7.png" alt="blog dbdiagram" width="800" height="745"&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Exporting SQL Scripts
&lt;/h3&gt;

&lt;p&gt;Once your schema is complete, dbdiagram can generate the equivalent SQL for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;PostgreSQL&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MySQL&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SQL Server&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SQLite&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just hit &lt;code&gt;Export &amp;gt; SQL&lt;/code&gt; and you’re ready to run it in your database setup.&lt;/p&gt;




&lt;h3&gt;
  
  
  Collaboration &amp;amp; Sharing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Version control friendly&lt;/strong&gt; – Save your dbml code in &lt;code&gt;.dbml&lt;/code&gt; files in GitHub&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Share via link&lt;/strong&gt; – Collaborators can view your schema without signing up&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Teams&lt;/strong&gt; – Upgrade to a team plan to collaborate in real-time&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Tips for Better Schema Design
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Always use &lt;code&gt;id&lt;/code&gt; as primary key unless you &lt;strong&gt;really&lt;/strong&gt; need composite keys.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;created_at&lt;/code&gt; and &lt;code&gt;updated_at&lt;/code&gt; fields for better tracking.&lt;/li&gt;
&lt;li&gt;Use foreign keys to define relationships instead of managing them manually.&lt;/li&gt;
&lt;li&gt;Normalize, but don’t over-normalize. Balance is key.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;ENUM&lt;/code&gt; or &lt;code&gt;lookup tables&lt;/code&gt; for things like post status, user roles, etc.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Whether you're a solo developer working on your next SaaS idea, or part of a big team managing microservices, &lt;strong&gt;dbdiagram.io is a game-changer&lt;/strong&gt; for designing and communicating your database architecture.&lt;/p&gt;

&lt;p&gt;It saves you from visual mess, enforces good structure, and helps your team stay aligned, all without needing to open MySQL Workbench.&lt;/p&gt;




&lt;h4&gt;
  
  
  Useful Links
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Try it here: &lt;a href="https://dbdiagram.io" rel="noopener noreferrer"&gt;dbdiagram.io&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Full documentation: &lt;a href="https://dbdocs.io/docs" rel="noopener noreferrer"&gt;dbdocs.io/docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub-friendly DBML: &lt;a href="https://github.com/holistics/dbml" rel="noopener noreferrer"&gt;https://github.com/holistics/dbml&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If you loved this breakdown, let me know! Want me to cover more visual dev tools like this? Drop a comment.&lt;/p&gt;

</description>
      <category>database</category>
      <category>mysql</category>
      <category>sql</category>
      <category>postgres</category>
    </item>
    <item>
      <title>🚀 10 Laravel Eloquent Tricks You Didn’t Know (But Will Love!)</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Mon, 21 Apr 2025 15:06:04 +0000</pubDate>
      <link>https://dev.to/arafatweb/10-laravel-eloquent-tricks-you-didnt-know-but-will-love-505c</link>
      <guid>https://dev.to/arafatweb/10-laravel-eloquent-tricks-you-didnt-know-but-will-love-505c</guid>
      <description>&lt;p&gt;Laravel’s Eloquent ORM is one of the most powerful tools in the PHP ecosystem. But let’s be honest, most developers stick to &lt;code&gt;get()&lt;/code&gt;, &lt;code&gt;where()&lt;/code&gt;, and &lt;code&gt;find()&lt;/code&gt;. Eloquent actually has many hidden features that can help you write cleaner, faster, and more maintainable code.&lt;/p&gt;

&lt;p&gt;In this blog, you’ll discover 10 lesser-known Eloquent methods and techniques that will level up your Laravel skills.&lt;/p&gt;

&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
withWhereHas() – Filter and Eager Load in One Query
&lt;/li&gt;
&lt;li&gt;
cursorPaginate() – Paginate Large Datasets Efficiently
&lt;/li&gt;
&lt;li&gt;
sole() – Ensure Only One Record Exists
&lt;/li&gt;
&lt;li&gt;
upsert() – Insert or Update Multiple Rows at Once
&lt;/li&gt;
&lt;li&gt;
lazy() – Loop Through Big Data Without Memory Issues
&lt;/li&gt;
&lt;li&gt;
findMany() – Fetch Multiple Records Easily
&lt;/li&gt;
&lt;li&gt;
whereBelongsTo() – Query Using a Model Instance
&lt;/li&gt;
&lt;li&gt;
is() – Compare Models Safely
&lt;/li&gt;
&lt;li&gt;
firstOrCreate() and updateOrCreate() – Atomic Record Handling
&lt;/li&gt;
&lt;li&gt;tap() – Inspect Queries in the Middle of a Chain&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  1. withWhereHas() – Filter and Eager Load in One Query
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;withWhereHas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'comments'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'approved'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoids multiple queries&lt;/li&gt;
&lt;li&gt;Reduces memory usage&lt;/li&gt;
&lt;li&gt;Keeps your code concise&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. cursorPaginate() – Paginate Large Datasets Efficiently
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;orderBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;cursorPaginate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Great for infinite scroll or continuous loading&lt;/li&gt;
&lt;li&gt;Handles large datasets without slowing down&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. sole() – Ensure Only One Record Exists
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'admin@example.com'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;sole&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Eliminates silent bugs&lt;/li&gt;
&lt;li&gt;Ensures data uniqueness and consistency&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. upsert() – Insert or Update Multiple Rows at Once
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;upsert&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="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'one@test.com'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'User One'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'two@test.com'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'User Two'&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="s1"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="c1"&gt;// Unique column&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="c1"&gt;// Columns to update&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prevents duplicates&lt;/li&gt;
&lt;li&gt;Minimizes database load&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. lazy() – Loop Through Big Data Without Memory Issues
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;each&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Process user&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keeps memory usage low&lt;/li&gt;
&lt;li&gt;Perfect for batch jobs, exports, and reporting&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. findMany() – Fetch Multiple Records Easily
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;findMany&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cleaner syntax&lt;/li&gt;
&lt;li&gt;More efficient than multiple queries&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. whereBelongsTo() – Query Using a Model Instance
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;whereBelongsTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More readable and expressive&lt;/li&gt;
&lt;li&gt;Helps when working directly with models&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. is() – Compare Models Safely
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$post&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;author&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;is&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$currentUser&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Perform action&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Safer than manual comparisons&lt;/li&gt;
&lt;li&gt;Works with unsaved models too&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  9. firstOrCreate() and updateOrCreate() – Atomic Record Handling
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;updateOrCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'someone@example.com'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Someone New'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoids duplicate records&lt;/li&gt;
&lt;li&gt;Clean and readable&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  10. tap() – Inspect Queries in the Middle of a Chain
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;tap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;toSql&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Great for debugging&lt;/li&gt;
&lt;li&gt;Keeps the method chain intact&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Laravel Eloquent is packed with powerful features that go beyond the basics. By using these lesser-known methods, you can write code that is not only more efficient but also easier to maintain and scale.&lt;/p&gt;

&lt;p&gt;Whether you're building APIs, admin panels, or full-blown applications, these tips will give your Laravel skills an extra edge.&lt;/p&gt;

&lt;h3&gt;
  
  
  Useful Links
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://laravel.com/docs/eloquent" rel="noopener noreferrer"&gt;Official Eloquent Documentation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/arafatweb"&gt;More Laravel Tips on Dev.to&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/arafat-web" rel="noopener noreferrer"&gt;Follow Me on GitHub&lt;/a&gt; for Laravel projects and tutorials&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Building a PHP CRUD Application with OOP and MySQL: A Best Practice Guide</title>
      <dc:creator>Arafat Hossain Ar</dc:creator>
      <pubDate>Fri, 10 Jan 2025 15:58:16 +0000</pubDate>
      <link>https://dev.to/arafatweb/building-a-php-crud-application-with-oop-and-mysql-a-best-practice-guide-19p</link>
      <guid>https://dev.to/arafatweb/building-a-php-crud-application-with-oop-and-mysql-a-best-practice-guide-19p</guid>
      <description>&lt;p&gt;When developing PHP applications, managing database operations effectively is crucial. One of the most common operations you’ll perform is CRUD (Create, Read, Update, Delete). Adopting Object-Oriented Programming (OOP) principles helps make your code cleaner, reusable, and scalable. Using MySQL with PHP also ensures that your application can handle data storage efficiently.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll go through building a &lt;strong&gt;PHP CRUD application&lt;/strong&gt; with &lt;strong&gt;OOP&lt;/strong&gt; and &lt;strong&gt;MySQL&lt;/strong&gt;. We’ll organize the code using best practices and design patterns that are beginner-friendly yet robust enough for larger projects.&lt;/p&gt;

&lt;p&gt;By the end of this guide, you will have a solid foundation for working with databases using OOP principles in PHP.&lt;/p&gt;

&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;The Importance of OOP in PHP&lt;/li&gt;
&lt;li&gt;Setting Up the Project&lt;/li&gt;
&lt;li&gt;Creating the Database&lt;/li&gt;
&lt;li&gt;Folder Structure&lt;/li&gt;
&lt;li&gt;Connecting to the Database&lt;/li&gt;
&lt;li&gt;
Creating CRUD Operations

&lt;ul&gt;
&lt;li&gt;Create&lt;/li&gt;
&lt;li&gt;Read&lt;/li&gt;
&lt;li&gt;Update&lt;/li&gt;
&lt;li&gt;Delete&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  1. The Importance of OOP in PHP
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Object-Oriented Programming (OOP)&lt;/strong&gt; is a programming paradigm that uses "objects" to organize code. In PHP, OOP allows you to create classes that represent real-world entities, making your code more modular, reusable, and easier to manage.&lt;/p&gt;

&lt;p&gt;When working with databases, applying OOP principles means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Separation of Concerns&lt;/strong&gt;: Database logic is encapsulated in a class, separate from the rest of your application logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reusability&lt;/strong&gt;: You can reuse the database class in multiple parts of the application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintainability&lt;/strong&gt;: Your code is easier to update and extend as your application grows.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Setting Up the Project
&lt;/h3&gt;

&lt;p&gt;Before diving into coding, let’s set up a folder structure that’s easy to maintain. Here’s how your project should be organized:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php-crud/
├── config/
│   └── Database.php
├── controllers/
│   └── UserController.php
├── models/
│   └── User.php
├── views/
│   └── user_list.php
├── public/
│   └── index.php
└── .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;config/Database.php&lt;/strong&gt;: Contains the database connection logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;controllers/UserController.php&lt;/strong&gt;: Handles CRUD operations and communicates with the model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;models/User.php&lt;/strong&gt;: Contains the logic to interact with the &lt;code&gt;users&lt;/code&gt; table in MySQL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;views/user_list.php&lt;/strong&gt;: Displays user data in a table.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;public/index.php&lt;/strong&gt;: The entry point for the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Creating the Database
&lt;/h3&gt;

&lt;p&gt;Let’s start by creating the database and a &lt;code&gt;users&lt;/code&gt; table in MySQL. You can execute the following SQL queries to set up the database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;DATABASE&lt;/span&gt; &lt;span class="n"&gt;php_crud&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;USE&lt;/span&gt; &lt;span class="n"&gt;php_crud&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="n"&gt;AUTO_INCREMENT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="nb"&gt;TIMESTAMP&lt;/span&gt; &lt;span class="k"&gt;DEFAULT&lt;/span&gt; &lt;span class="k"&gt;CURRENT_TIMESTAMP&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This table will store basic user information such as &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt;, and &lt;code&gt;created_at&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Folder Structure
&lt;/h3&gt;

&lt;p&gt;We’ve already set up the basic folder structure. Here’s a breakdown of each folder’s purpose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;config/&lt;/strong&gt;: Contains the database configuration and connection logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;controllers/&lt;/strong&gt;: Handles requests and calls the appropriate methods from the model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;models/&lt;/strong&gt;: Represents the business logic and database interactions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;views/&lt;/strong&gt;: Displays the data to the user.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;public/&lt;/strong&gt;: The public folder contains the &lt;code&gt;index.php&lt;/code&gt; file, which will be the entry point for the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Connecting to the Database
&lt;/h3&gt;

&lt;p&gt;Let’s start by creating a database connection class in &lt;code&gt;config/Database.php&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;Config&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="no"&gt;PDO&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;Database&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'127.0.0.1'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$dbName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'php_crud'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'root'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$connection&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PDO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="s2"&gt;"mysql:host=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;dbname=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;dbName&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;
            &lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;PDO&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;ATTR_ERRMODE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;PDO&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;ERRMODE_EXCEPTION&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;PDOException&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;die&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Database connection failed: "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getMessage&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This class creates a PDO connection to MySQL and is reusable across your project.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Creating CRUD Operations
&lt;/h3&gt;

&lt;p&gt;Let’s create a model for handling user data. This class will interact with the &lt;code&gt;users&lt;/code&gt; table and perform CRUD operations.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Create Model (User.php)&lt;/strong&gt;
&lt;/h4&gt;



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

&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;Models&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Config\Database&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="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$conn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$database&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$database&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$sql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"INSERT INTO users (name, email) VALUES (:name, :email)"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$sql&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bindParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;':name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bindParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;':email'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$sql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SELECT * FROM users"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$sql&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;fetchAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;\PDO&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;FETCH_ASSOC&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$sql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"UPDATE users SET name = :name, email = :email WHERE id = :id"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$sql&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bindParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;':name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bindParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;':email'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bindParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;':id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$sql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"DELETE FROM users WHERE id = :id"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$sql&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bindParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;':id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Create Controller (UserController.php)&lt;/strong&gt;
&lt;/h4&gt;



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

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

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

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserController&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;updateUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;deleteUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Create View (user_list.php)&lt;/strong&gt;
&lt;/h4&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="c1"&gt;// This file is responsible for displaying the list of users.&lt;/span&gt;

&lt;span class="k"&gt;require_once&lt;/span&gt; &lt;span class="k"&gt;__DIR__&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/../controllers/UserController.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$userController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;\Controllers\UserController&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nv"&gt;$users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$userController&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;h1&amp;gt;User List&amp;lt;/h1&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;ID&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Actions&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$users&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;a href='update.php?id=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;'&amp;gt;Edit&amp;lt;/a&amp;gt; | &amp;lt;a href='delete.php?id=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;'&amp;gt;Delete&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;/table&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Create the Entry Point (index.php)&lt;/strong&gt;
&lt;/h4&gt;



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

&lt;span class="k"&gt;require_once&lt;/span&gt; &lt;span class="k"&gt;__DIR__&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/../models/User.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;require_once&lt;/span&gt; &lt;span class="k"&gt;__DIR__&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/../controllers/UserController.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$userController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;\Controllers\UserController&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Example: Create a user&lt;/span&gt;
&lt;span class="nv"&gt;$userController&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'John Doe'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'john@example.com'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Example: Read users&lt;/span&gt;
&lt;span class="nv"&gt;$userController&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;By following OOP principles and applying best practices in PHP, we’ve built a simple and scalable CRUD application. This approach makes it easy to expand your project with new features or improve database interactions.&lt;/p&gt;

&lt;p&gt;In this guide, we’ve covered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A simple and maintainable folder structure.&lt;/li&gt;
&lt;li&gt;A reusable &lt;code&gt;Database&lt;/code&gt; class for MySQL connections.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;User&lt;/code&gt; model that encapsulates all CRUD operations.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;UserController&lt;/code&gt; to handle business logic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This structure makes your PHP applications cleaner, more modular, and easier to extend. You can now take this approach and build larger, more complex applications using OOP and MySQL.&lt;/p&gt;

&lt;p&gt;Happy coding! 🎉&lt;/p&gt;

</description>
      <category>php</category>
      <category>oop</category>
      <category>sql</category>
      <category>mysql</category>
    </item>
  </channel>
</rss>
