<?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: Mohamed Abdelwahed</title>
    <description>The latest articles on DEV Community by Mohamed Abdelwahed (@mo7amed_3bdalla7).</description>
    <link>https://dev.to/mo7amed_3bdalla7</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F29504%2Fafc5a8f8-1234-4ffa-aba7-7f7a72e9d6ba.jpeg</url>
      <title>DEV Community: Mohamed Abdelwahed</title>
      <link>https://dev.to/mo7amed_3bdalla7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mo7amed_3bdalla7"/>
    <language>en</language>
    <item>
      <title>When Not to Use DB Indexes</title>
      <dc:creator>Mohamed Abdelwahed</dc:creator>
      <pubDate>Thu, 01 May 2025 06:44:07 +0000</pubDate>
      <link>https://dev.to/mo7amed_3bdalla7/when-not-to-use-db-indexes-8fn</link>
      <guid>https://dev.to/mo7amed_3bdalla7/when-not-to-use-db-indexes-8fn</guid>
      <description>&lt;h2&gt;
  
  
  Avoid Indexing DB Columns with Highly Repeated Values
&lt;/h2&gt;

&lt;p&gt;Indexing is a powerful tool in databases that can dramatically improve query performance when used appropriately. However, not all indices are created equal regarding impact and efficiency. A common mistake developers make is adding indexes to columns that contain highly repeated (low-cardinality) values. In most cases, this wastes resources and can degrade performance. Here's why.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding Indexes in PostgreSQL
&lt;/h3&gt;

&lt;p&gt;An index in PostgreSQL is essentially a data structure (commonly a B-tree) that allows the database engine to quickly locate rows matching a condition. Indexes shine when they help narrow down the number of rows PostgreSQL needs to scan, especially in large tables.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem with Low-Cardinality Columns
&lt;/h3&gt;

&lt;p&gt;Low-cardinality columns are those where the number of distinct values is small compared to the total number of rows. For example, a status column with values like &lt;code&gt;active&lt;/code&gt;, &lt;code&gt;inactive&lt;/code&gt;, or &lt;code&gt;archived&lt;/code&gt;, in a table of millions of rows, is low in cardinality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why indexing them is usually a bad idea:
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Low Selectivity
&lt;/h4&gt;

&lt;p&gt;Indexes are effective when they help filter out large portions of the data. If 90% of your table has &lt;code&gt;status = 'active'&lt;/code&gt;, an index won't help much — PostgreSQL will likely fall back to a sequential scan because it's cheaper than jumping back and forth between the index and table rows (known as "random I/O").&lt;/p&gt;

&lt;h4&gt;
  
  
  Extra Overhead on Writes
&lt;/h4&gt;

&lt;p&gt;Every time you INSERT, UPDATE, or DELETE a row, PostgreSQL must update any indexes that involve that row. If your low-cardinality column has an index, you're paying the overhead for maintaining it — with little or no performance gain in reads.&lt;/p&gt;

&lt;h4&gt;
  
  
  Bloated Indexes
&lt;/h4&gt;

&lt;p&gt;Indexes on repetitive values often result in large, inefficient index structures that waste disk space and can lead to slower maintenance operations like VACUUM or ANALYZE.&lt;/p&gt;

&lt;h4&gt;
  
  
  Query Planner Might Ignore It
&lt;/h4&gt;

&lt;p&gt;PostgreSQL is smart. It analyzes data distribution and will avoid using indexes if they don't offer performance benefits. So even if you create an index on a column like &lt;code&gt;is_active&lt;/code&gt;, PostgreSQL might not use it in queries unless the distribution changes significantly.&lt;/p&gt;

&lt;h3&gt;
  
  
  When It Might Be Okay
&lt;/h3&gt;

&lt;p&gt;There are exceptions. Indexing a low-cardinality column can make sense if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The table is relatively small, and you're optimizing for a very frequent query&lt;/li&gt;
&lt;li&gt;The column is combined with other, more selective columns in a composite index&lt;/li&gt;
&lt;li&gt;You're using partial indexes — e.g., &lt;code&gt;CREATE INDEX ON users (id) WHERE status = 'archived'&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You're optimizing for index-only scans and the column is in a covering index&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Better Alternatives
&lt;/h3&gt;

&lt;p&gt;Instead of blindly indexing low-cardinality columns, consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Partial indexes&lt;/strong&gt;: Useful when queries always filter on specific values&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multicolumn indexes&lt;/strong&gt;: More selective when used with additional filtering criteria&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Materialized views&lt;/strong&gt;: For precomputed subsets of data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Denormalization or restructuring&lt;/strong&gt;: Sometimes, changing schema design helps more than indexing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Indexes are a powerful but limited resource. Indexing a column with highly repeated values in PostgreSQL often results in little to no performance gain and unnecessary overhead. Before creating an index, always consider the cardinality of the column and analyze your query patterns. Use tools like &lt;code&gt;EXPLAIN ANALYZE&lt;/code&gt; to measure actual query performance and validate whether an index is truly beneficial.&lt;/p&gt;

</description>
      <category>database</category>
      <category>postgressql</category>
      <category>mysql</category>
      <category>dbindex</category>
    </item>
    <item>
      <title>Efficient Python Dependency Management with uv in Docker for FastAPI</title>
      <dc:creator>Mohamed Abdelwahed</dc:creator>
      <pubDate>Wed, 05 Mar 2025 08:28:10 +0000</pubDate>
      <link>https://dev.to/mo7amed_3bdalla7/efficient-python-dependency-management-with-uv-in-docker-for-fastapi-1oe1</link>
      <guid>https://dev.to/mo7amed_3bdalla7/efficient-python-dependency-management-with-uv-in-docker-for-fastapi-1oe1</guid>
      <description>&lt;p&gt;In modern Python development, managing project dependencies efficiently is crucial for optimizing both development and production environments. In this post, we'll focus on using the &lt;code&gt;uv&lt;/code&gt; package manager to streamline Python dependency management in a Dockerized FastAPI application.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Role of &lt;code&gt;uv&lt;/code&gt; in Dependency Management
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;uv&lt;/code&gt; is a high-performance package manager designed to make Python dependency management faster, more reproducible, and less resource-intensive. Unlike traditional tools like &lt;code&gt;pip&lt;/code&gt; and &lt;code&gt;virtualenv&lt;/code&gt;, &lt;code&gt;uv&lt;/code&gt; focuses on reducing complexity and enhancing speed by syncing your dependencies based on a lock file. By using &lt;code&gt;uv&lt;/code&gt;, you can ensure that only the necessary system dependencies are installed, avoiding unnecessary overhead and improving the overall performance of your containerized application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dockerfile for FastAPI Application with &lt;code&gt;uv&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:3.12-alpine&lt;/span&gt;

&lt;span class="c"&gt;# Install system dependencies required by uv&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;apk add &lt;span class="nt"&gt;--no-cache&lt;/span&gt; curl git

&lt;span class="c"&gt;# Install uv safely&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;curl &lt;span class="nt"&gt;-LsSf&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; /tmp/install_uv.sh https://astral.sh/uv/install.sh &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;    sh /tmp/install_uv.sh &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="nb"&gt;rm&lt;/span&gt; /tmp/install_uv.sh

&lt;span class="c"&gt;# Set PATH to include uv&lt;/span&gt;
&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; PATH="/root/.local/bin:$PATH"&lt;/span&gt;

&lt;span class="c"&gt;# Create app directory and set permissions&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="c"&gt;# Copy dependency files first for caching&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; pyproject.toml uv.lock ./&lt;/span&gt;

&lt;span class="c"&gt;# Install dependencies using uv&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;uv &lt;span class="nb"&gt;sync&lt;/span&gt; &lt;span class="nt"&gt;--frozen&lt;/span&gt; &lt;span class="nt"&gt;--no-install-project&lt;/span&gt; &lt;span class="nt"&gt;--no-dev&lt;/span&gt; &lt;span class="nt"&gt;--python-preference&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;only-system

&lt;span class="c"&gt;# Copy the rest of the project files&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . .&lt;/span&gt;

&lt;span class="c"&gt;# Run the FastAPI application&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Breakdown of the Dockerfile and &lt;code&gt;uv&lt;/code&gt; Integration
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. &lt;strong&gt;Base Image and System Dependencies&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:3.12-alpine&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;apk add &lt;span class="nt"&gt;--no-cache&lt;/span&gt; curl git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We start by using the official &lt;code&gt;python:3.12-alpine&lt;/code&gt; image, which is optimized for small size. Then, we install system dependencies &lt;code&gt;curl&lt;/code&gt; and &lt;code&gt;git&lt;/code&gt;, which are required for installing &lt;code&gt;uv&lt;/code&gt; and potentially fetching git-based dependencies.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. &lt;strong&gt;Installing &lt;code&gt;uv&lt;/code&gt;&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;curl &lt;span class="nt"&gt;-LsSf&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; /tmp/install_uv.sh https://astral.sh/uv/install.sh &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;    sh /tmp/install_uv.sh &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="nb"&gt;rm&lt;/span&gt; /tmp/install_uv.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The core of this Dockerfile is the installation of the &lt;code&gt;uv&lt;/code&gt; package manager. &lt;code&gt;uv&lt;/code&gt; is installed by downloading and running the installer script. This step ensures that your project uses a fast, consistent, and lean dependency management tool. The installer script installs &lt;code&gt;uv&lt;/code&gt; to the &lt;code&gt;/root/.local/bin&lt;/code&gt; directory.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. &lt;strong&gt;Setting Up &lt;code&gt;uv&lt;/code&gt; in the Environment&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; PATH="/root/.local/bin:$PATH"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we add the directory where &lt;code&gt;uv&lt;/code&gt; is installed to the &lt;code&gt;PATH&lt;/code&gt; environment variable, ensuring it is accessible in subsequent Docker commands.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. &lt;strong&gt;Copying Dependency Files and Installing Dependencies&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; pyproject.toml uv.lock ./&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;uv &lt;span class="nb"&gt;sync&lt;/span&gt; &lt;span class="nt"&gt;--frozen&lt;/span&gt; &lt;span class="nt"&gt;--no-install-project&lt;/span&gt; &lt;span class="nt"&gt;--no-dev&lt;/span&gt; &lt;span class="nt"&gt;--python-preference&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;only-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We copy the &lt;code&gt;pyproject.toml&lt;/code&gt; and &lt;code&gt;uv.lock&lt;/code&gt; files, which contain all the necessary dependency information for the project.&lt;/li&gt;
&lt;li&gt;We then use &lt;code&gt;uv sync&lt;/code&gt; to install dependencies. The &lt;code&gt;--frozen&lt;/code&gt; flag ensures that the exact versions from &lt;code&gt;uv.lock&lt;/code&gt; are used, and &lt;code&gt;--no-install-project&lt;/code&gt; avoids installing the project itself, focusing solely on dependencies. The &lt;code&gt;--no-dev&lt;/code&gt; option skips installing development dependencies, while &lt;code&gt;--python-preference=only-system&lt;/code&gt; ensures system dependencies are prioritized, minimizing the size of the image.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  5. &lt;strong&gt;Copying Application Code&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . .&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command copies the remaining application files into the container. Since dependencies were already installed earlier, Docker will skip unnecessary installations if the code changes.&lt;/p&gt;

&lt;h4&gt;
  
  
  6. &lt;strong&gt;Running the FastAPI Application&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we use &lt;code&gt;uv&lt;/code&gt; to launch the FastAPI application with &lt;code&gt;uvicorn&lt;/code&gt; as the ASGI server. The app is configured to listen on port 80, and &lt;code&gt;0.0.0.0&lt;/code&gt; ensures it's accessible externally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Choose &lt;code&gt;uv&lt;/code&gt;?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Speed&lt;/strong&gt;: &lt;code&gt;uv&lt;/code&gt; is optimized for performance and installs dependencies faster than traditional tools, especially in containerized environments where build times matter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reproducibility&lt;/strong&gt;: By relying on &lt;code&gt;uv.lock&lt;/code&gt; and using the &lt;code&gt;--frozen&lt;/code&gt; flag, you ensure that every environment running the Docker container uses the same dependency versions, making builds more predictable and stable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lean Builds&lt;/strong&gt;: &lt;code&gt;uv&lt;/code&gt; avoids unnecessary installations of development dependencies or redundant Python packages, reducing the overall size of your Docker image.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Using &lt;code&gt;uv&lt;/code&gt; in your Dockerfile offers significant improvements in dependency management, speed, and image size. The approach outlined here ensures that your FastAPI application is built on a reproducible, efficient foundation, making it easy to deploy and scale. By integrating &lt;code&gt;uv&lt;/code&gt;, you not only streamline the installation process but also improve the overall stability and performance of your application in production environments.&lt;/p&gt;

</description>
      <category>uv</category>
      <category>fastapi</category>
      <category>docker</category>
      <category>python</category>
    </item>
    <item>
      <title>Makefiles Make It Easy</title>
      <dc:creator>Mohamed Abdelwahed</dc:creator>
      <pubDate>Fri, 15 May 2020 21:35:06 +0000</pubDate>
      <link>https://dev.to/mo7amed_3bdalla7/makefiles-make-it-easy-13jl</link>
      <guid>https://dev.to/mo7amed_3bdalla7/makefiles-make-it-easy-13jl</guid>
      <description>&lt;p&gt;Sometimes when we developing applications we have a lot of commands for a run, test, format code, etc. and those commands may be long and we want to alias it, for many reasons we can't memorize these commands and we want to share it with other team members to make development easy for this situation we will use &lt;code&gt;make&lt;/code&gt; utility to help us.&lt;/p&gt;

&lt;h1&gt;
  
  
  Lets Start
&lt;/h1&gt;

&lt;p&gt;To know more about Make program we can write this command in the terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;man&lt;/span&gt; &lt;span class="nt"&gt;make&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you should see something like this :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;make - GNU make utility to maintain groups of programs&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;if you faced any errors make sure that &lt;code&gt;make&lt;/code&gt; utility installed on your machine.&lt;/p&gt;

&lt;p&gt;as you see in &lt;code&gt;man make&lt;/code&gt; description that &lt;code&gt;make&lt;/code&gt; developed to make compile C programs easy and can be used in other tasks.&lt;/p&gt;

&lt;h1&gt;
  
  
  Install Make&lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;for most Linux distributions you will find make installed on your machine.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ubuntu run &lt;code&gt;sudo apt-get install build-essential&lt;/code&gt; for other distributions check your distro package manager.&lt;/li&gt;
&lt;li&gt;Mac OS run &lt;code&gt;xcode-select --install&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://gnuwin32.sourceforge.net/packages/make.htm" rel="noopener noreferrer"&gt;Windows&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Get your hands dirty
&lt;/h1&gt;

&lt;p&gt;Let us apply &lt;code&gt;make&lt;/code&gt; utility on a PHP lumen app for example if we want to run lumen app with PHP internal server we need to run this command &lt;code&gt;php -S localhost:8000 -t public&lt;/code&gt; in the terminal what if we make this command shorter to convert it only to &lt;code&gt;make serve&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a file in the application root folder named &lt;code&gt;makefile&lt;/code&gt; to tell &lt;code&gt;make&lt;/code&gt; what to do.&lt;/li&gt;
&lt;li&gt;Open &lt;code&gt;makefile&lt;/code&gt; and paste the next code snippet and make sure to use tabs not spaces :
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight make"&gt;&lt;code&gt;&lt;span class="nl"&gt;serve&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
        php &lt;span class="nt"&gt;-S&lt;/span&gt; localhost:8000 &lt;span class="nt"&gt;-t&lt;/span&gt; public
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Run &lt;code&gt;make serve&lt;/code&gt; in the terminal instead of &lt;br&gt;
&lt;code&gt;php -S localhost:8000 -t public&lt;/code&gt; this is a basic usage for makerfile.&lt;/p&gt;
&lt;h1&gt;
  
  
  Lets Explain
&lt;/h1&gt;

&lt;p&gt;Makefile consists of rules as the next structure of the rule :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight make"&gt;&lt;code&gt;&lt;span class="nl"&gt;target … &lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;prerequisites …&lt;/span&gt;
        recipe
        …
        …
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;makefiles have a lot of detail but we will explain what we need in our scope so let us describe &lt;code&gt;make&lt;/code&gt; rule as :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Before &lt;code&gt;:&lt;/code&gt; this the name we will execute the rule with.&lt;/li&gt;
&lt;li&gt;After &lt;code&gt;:&lt;/code&gt; this is a list of prerequisites rule we declared before and want to run before The rule.&lt;/li&gt;
&lt;li&gt;Next line starts with tab  contain a command we want to run or script consists of several lines.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Example
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight make"&gt;&lt;code&gt;&lt;span class="c"&gt;#Variables
&lt;/span&gt;&lt;span class="nv"&gt;PHP&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; php

&lt;span class="c"&gt;#Rules
&lt;/span&gt;&lt;span class="nl"&gt;serve&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;$(&lt;/span&gt;PHP&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nt"&gt;-S&lt;/span&gt; localhost:8000 &lt;span class="nt"&gt;-t&lt;/span&gt; public

&lt;span class="nl"&gt;test&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
        ./vendor/bin/phpunit

&lt;span class="nl"&gt;fresh-db&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;$(&lt;/span&gt;PHP&lt;span class="p"&gt;)&lt;/span&gt; artisan migrate:fresh

&lt;span class="nl"&gt;fresh-serve&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;fresh-db serve&lt;/span&gt;

&lt;span class="nl"&gt;fresh-test&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;fresh-db test&lt;/span&gt;
        &lt;span class="nb"&gt;echo &lt;/span&gt;Done&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Expalination
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can run any rule just by type &lt;code&gt;make rule-name&lt;/code&gt; terminal opened in your app root folder with makefile in it.&lt;/li&gt;
&lt;li&gt;As in the first block of the file, we can declare variables to reuse them with &lt;code&gt;$(VariableName)&lt;/code&gt; notation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;serve&lt;/code&gt;, &lt;code&gt;test&lt;/code&gt; and &lt;code&gt;fresh-db&lt;/code&gt; rules only execute a command you can write any bash command.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fresh-serve&lt;/code&gt; rule runs the &lt;code&gt;fresh-db&lt;/code&gt; and &lt;code&gt;serve&lt;/code&gt; rules as prerequisites.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fresh-test&lt;/code&gt; rule runs the &lt;code&gt;fresh-db&lt;/code&gt; and &lt;code&gt;test&lt;/code&gt; rules as prerequisites and bash &lt;code&gt;echo&lt;/code&gt; command.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I can't cover all &lt;code&gt;make&lt;/code&gt; features in one article I just want to explain how I use makefiles to the development process easy you use it with any technology stack you want.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents" rel="noopener noreferrer"&gt;GNU make&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>make</category>
      <category>makefile</category>
      <category>php</category>
      <category>lumen</category>
    </item>
  </channel>
</rss>
