<?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>Forem: Salma</title>
    <description>The latest articles on Forem by Salma (@salmazz).</description>
    <link>https://forem.com/salmazz</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%2F580955%2Fc4a44053-a71a-4e04-8a26-e2b76bedcc2d.png</url>
      <title>Forem: Salma</title>
      <link>https://forem.com/salmazz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/salmazz"/>
    <language>en</language>
    <item>
      <title>Laravel Blueprint To built fast laravel app</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Fri, 24 Jan 2025 17:44:07 +0000</pubDate>
      <link>https://forem.com/salmazz/laravel-blueprint-to-built-fast-laravel-app-ifg</link>
      <guid>https://forem.com/salmazz/laravel-blueprint-to-built-fast-laravel-app-ifg</guid>
      <description>&lt;p&gt;Hey developers!  Today, I want to share a personal story about how Laravel's Blueprint significantly streamlined my development process, especially when it came to handling migrations, models, and factories. It's a game-changer, and here's why.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rapid Database Setup with Migrations&lt;/strong&gt;&lt;br&gt;
Blueprint in Laravel isn't just about creating tables; it's about setting up your entire database environment swiftly and efficiently. With a few lines of code, I was able to define my tables, columns, and relationships. No more manual SQL! Here’s a quick snippet:&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;Schema&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'products'&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="kt"&gt;Blueprint&lt;/span&gt; &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;string&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;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'price'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$table&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timestamps&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;Effortless Model Creation&lt;/strong&gt;&lt;br&gt;
Once the migrations were in place, setting up Eloquent models was straightforward. Laravel's artisan command &lt;code&gt;php artisan make:model Product&lt;/code&gt; instantly created a model based on my migration. This tight integration ensures consistency across your database and application logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run and Relax&lt;/strong&gt;&lt;br&gt;
With all pieces in place – migrations, models, and factories – deploying changes and testing them became a matter of running a few commands. &lt;code&gt;php artisan migrate&lt;/code&gt;, &lt;code&gt;php artisan db:seed&lt;/code&gt;, and I was ready to test my application with a rich, well-structured database.&lt;/p&gt;

&lt;p&gt;Absolutely! If you're starting a new project in Laravel and want to leverage Blueprint to streamline your development process, here's a step-by-step guide to get you up and running:&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Install Laravel
&lt;/h3&gt;

&lt;p&gt;First, you need to create a new Laravel project. If you haven't already, you can do this using Composer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer create-project &lt;span class="nt"&gt;--prefer-dist&lt;/span&gt; laravel/laravel your-project-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Navigate into your project directory:&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;cd &lt;/span&gt;your-project-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Set Up Your Database
&lt;/h3&gt;

&lt;p&gt;Before you start using Blueprint, make sure your database is configured. Open the &lt;code&gt;.env&lt;/code&gt; file in your project root and update the database configuration settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_user
DB_PASSWORD=your_database_password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Install Blueprint
&lt;/h3&gt;

&lt;p&gt;Blueprint is a package that helps you generate migrations, models, controllers, and more from a single configuration file. You can install it via Composer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require &lt;span class="nt"&gt;--dev&lt;/span&gt; laravel-shift/blueprint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Create a Blueprint Configuration File
&lt;/h3&gt;

&lt;p&gt;Blueprint uses a &lt;code&gt;draft.yaml&lt;/code&gt; file to define your database schema and other configurations. Create this file in the root of your project:&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;touch &lt;/span&gt;draft.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Define Your Schema in &lt;code&gt;draft.yaml&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Open the &lt;code&gt;draft.yaml&lt;/code&gt; file and define your database schema. Here’s an example of how you might define a &lt;code&gt;products&lt;/code&gt; table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;models&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;Product&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;string&lt;/span&gt;
    &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;decimal:8,2&lt;/span&gt;
    &lt;span class="na"&gt;timestamps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;~&lt;/span&gt;

&lt;span class="na"&gt;controllers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;Product&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;resource&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration will generate a migration, model, and controller for the &lt;code&gt;Product&lt;/code&gt; entity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Generate Migrations, Models, and Controllers
&lt;/h3&gt;

&lt;p&gt;Once your &lt;code&gt;draft.yaml&lt;/code&gt; file is ready, you can use Blueprint to generate the necessary files. Run the following command:&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 blueprint:build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will generate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A migration file for the &lt;code&gt;products&lt;/code&gt; table.&lt;/li&gt;
&lt;li&gt;An Eloquent model for the &lt;code&gt;Product&lt;/code&gt; entity.&lt;/li&gt;
&lt;li&gt;A controller for handling web requests related to products.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 7: Run Migrations
&lt;/h3&gt;

&lt;p&gt;Now that your migration files are generated, you can run them to create the tables in your database:&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 8: Seed Your Database (Optional)
&lt;/h3&gt;

&lt;p&gt;If you want to populate your database with test data, you can create seeders. Blueprint can also help with this. Add seeders to your &lt;code&gt;draft.yaml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;seeders&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;Product&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Sample&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Product'&lt;/span&gt;
      &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;19.99&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, generate the seeder:&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 blueprint:build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, run the seeder:&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 db:seed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 9: Test Your Application
&lt;/h3&gt;

&lt;p&gt;With everything set up, you can now test your application. Start the Laravel development server:&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 serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit your application in the browser and verify that everything is working as expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 10: Iterate and Expand
&lt;/h3&gt;

&lt;p&gt;As your project grows, you can continue to update your &lt;code&gt;draft.yaml&lt;/code&gt; file and use Blueprint to generate new migrations, models, controllers, and more. This iterative process ensures that your database and application logic remain consistent and up-to-date.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Blueprint has transformed my Laravel development process. It's not just about building things right; it's about building them fast and with precision. Whether you're setting up a new project or maintaining an existing one, integrating migrations, models, and factories via Blueprint can save hours of work and potential headaches.&lt;/p&gt;

&lt;p&gt;If you've been manually handling database changes or struggling with data consistency, give Blueprint a try – it might just change your development life!&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>database</category>
    </item>
    <item>
      <title>MySQL: Using and Enhancing `DATETIME` and `TIMESTAMP`</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Wed, 19 Jun 2024 18:48:49 +0000</pubDate>
      <link>https://forem.com/salmazz/mysql-using-and-enhancing-datetime-and-timestamp-4bpm</link>
      <guid>https://forem.com/salmazz/mysql-using-and-enhancing-datetime-and-timestamp-4bpm</guid>
      <description>&lt;h4&gt;
  
  
  Introduction
&lt;/h4&gt;

&lt;p&gt;In MySQL, &lt;code&gt;DATETIME&lt;/code&gt; and &lt;code&gt;TIMESTAMP&lt;/code&gt; are commonly used data types for storing temporal values. Although both serve the purpose of storing date and time, there are fundamental differences between them that affect their usage. This article will explore the differences between &lt;code&gt;DATETIME&lt;/code&gt; and &lt;code&gt;TIMESTAMP&lt;/code&gt;, and how to overcome some limitations of &lt;code&gt;DATETIME&lt;/code&gt; to leverage the advantages of &lt;code&gt;TIMESTAMP&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Differences Between &lt;code&gt;DATETIME&lt;/code&gt; and &lt;code&gt;TIMESTAMP&lt;/code&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Range:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DATETIME&lt;/strong&gt;: Can store values from &lt;code&gt;'1000-01-01 00:00:00'&lt;/code&gt; to &lt;code&gt;'9999-12-31 23:59:59'&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TIMESTAMP&lt;/strong&gt;: Can store values from &lt;code&gt;'1970-01-01 00:00:01'&lt;/code&gt; to &lt;code&gt;'2038-01-19 03:14:07'&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Storage:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DATETIME&lt;/strong&gt;: Stored as is, in date and time format, without relying on the time zone. It requires 8 bytes of storage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TIMESTAMP&lt;/strong&gt;: Stored as an integer representing the number of seconds since &lt;code&gt;1970-01-01 00:00:00 UTC&lt;/code&gt;. It requires 4 bytes of storage.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Time Zone:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DATETIME&lt;/strong&gt;: Does not depend on the time zone and stores the value as is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TIMESTAMP&lt;/strong&gt;: Affected by the current time zone of the MySQL server. When inserting or retrieving values, they are automatically converted between the local time and UTC.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Automatic Updates:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DATETIME&lt;/strong&gt;: Does not support automatic updates directly when a row is modified.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TIMESTAMP&lt;/strong&gt;: Can be set to automatically update the value when a row is modified using the options &lt;code&gt;DEFAULT CURRENT_TIMESTAMP&lt;/code&gt; and &lt;code&gt;ON UPDATE CURRENT_TIMESTAMP&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Enhancing &lt;code&gt;DATETIME&lt;/code&gt; Usage
&lt;/h4&gt;

&lt;p&gt;To overcome some limitations of the &lt;code&gt;DATETIME&lt;/code&gt; data type, you can follow these strategies:&lt;/p&gt;

&lt;h5&gt;
  
  
  1. Standardizing Time Zone
&lt;/h5&gt;

&lt;p&gt;To solve the issue of &lt;code&gt;DATETIME&lt;/code&gt; not adhering to the time zone, you can standardize all temporal operations at the database and application level to use UTC.&lt;/p&gt;

&lt;h6&gt;
  
  
  Setting the Database to Work in UTC:
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="k"&gt;GLOBAL&lt;/span&gt; &lt;span class="n"&gt;time_zone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'+00:00'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;time_zone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'+00:00'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  Converting Values to UTC on Insertion:
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;example_table&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event_time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CONVERT_TZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2024-06-19 12:30:00'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Your/Timezone'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'+00:00'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  Converting Values from UTC to Local Time on Retrieval:
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;CONVERT_TZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event_time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'+00:00'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Your/Timezone'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;local_event_time&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;example_table&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  2. Automatic Updates
&lt;/h5&gt;

&lt;p&gt;To automatically update &lt;code&gt;DATETIME&lt;/code&gt; values when a row is modified, you can use triggers.&lt;/p&gt;

&lt;h6&gt;
  
  
  Creating a Trigger to Update the Field on Modification:
&lt;/h6&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;TRIGGER&lt;/span&gt; &lt;span class="n"&gt;before_update_example_table&lt;/span&gt;
&lt;span class="k"&gt;BEFORE&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;example_table&lt;/span&gt;
&lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="k"&gt;EACH&lt;/span&gt; &lt;span class="k"&gt;ROW&lt;/span&gt;
&lt;span class="k"&gt;BEGIN&lt;/span&gt;
  &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="k"&gt;NEW&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;updated_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NOW&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  3. Using Default Values
&lt;/h5&gt;

&lt;p&gt;To set &lt;code&gt;DATETIME&lt;/code&gt; values automatically on insertion, you can assign default values using the &lt;code&gt;NOW()&lt;/code&gt; function.&lt;/p&gt;

&lt;h6&gt;
  
  
  Setting Default Fields:
&lt;/h6&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;TABLE&lt;/span&gt; &lt;span class="n"&gt;example_table&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="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="n"&gt;AUTO_INCREMENT&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;DATETIME&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;span class="n"&gt;updated_at&lt;/span&gt; &lt;span class="nb"&gt;DATETIME&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="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;UPDATE&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;h5&gt;
  
  
  4. Handling Precision
&lt;/h5&gt;

&lt;p&gt;If higher precision for times is needed, you can use &lt;code&gt;DATETIME(6)&lt;/code&gt; or &lt;code&gt;TIMESTAMP(6)&lt;/code&gt; to store times up to microsecond precision.&lt;/p&gt;

&lt;h6&gt;
  
  
  Creating a Table with Microsecond Precision:
&lt;/h6&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;TABLE&lt;/span&gt; &lt;span class="n"&gt;example_table&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="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="n"&gt;AUTO_INCREMENT&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;DATETIME&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&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;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;updated_at&lt;/span&gt; &lt;span class="nb"&gt;DATETIME&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&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;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;CURRENT_TIMESTAMP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&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;h5&gt;
  
  
  5. Handling Times in the Application
&lt;/h5&gt;

&lt;p&gt;Ensure your application handles times correctly by converting all times to UTC before storing them and converting them back to local time when displaying them to the user.&lt;/p&gt;

&lt;h6&gt;
  
  
  Example in PHP:
&lt;/h6&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Setting the application time zone to UTC&lt;/span&gt;
&lt;span class="nb"&gt;date_default_timezone_set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'UTC'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Storing the current time as UTC&lt;/span&gt;
&lt;span class="nv"&gt;$current_time_utc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Y-m-d H:i:s'&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;=&lt;/span&gt; &lt;span class="s2"&gt;"INSERT INTO example_table (event_time) VALUES ('&lt;/span&gt;&lt;span class="nv"&gt;$current_time_utc&lt;/span&gt;&lt;span class="s2"&gt;')"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Retrieving the time and converting it to local time&lt;/span&gt;
&lt;span class="nv"&gt;$event_time_utc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'2024-06-19 12:30:00'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$event_time_local&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;DateTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$event_time_utc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;DateTimeZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'UTC'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nv"&gt;$event_time_local&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setTimezone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;DateTimeZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Your/Timezone'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$event_time_local&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Y-m-d H:i:s'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;DATETIME&lt;/code&gt;&lt;/strong&gt;: Used for storing dates and times without time zone dependencies. Suitable for future events or fixed scheduling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/strong&gt;: Used for tracking time relative to the current time zone. Suitable for logging the time when data is inserted or updated.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Enhancing &lt;code&gt;DATETIME&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Standardizing Time Zone&lt;/strong&gt;: Use UTC to standardize times.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic Updates&lt;/strong&gt;: Use triggers to update fields automatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Default Values&lt;/strong&gt;: Set default values for the &lt;code&gt;DATETIME&lt;/code&gt; field.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Precision&lt;/strong&gt;: Use &lt;code&gt;DATETIME(6)&lt;/code&gt; for higher precision.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handling Times in the Application&lt;/strong&gt;: Correctly convert times between UTC and local time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following these strategies, you can leverage the benefits of &lt;code&gt;TIMESTAMP&lt;/code&gt; while using &lt;code&gt;DATETIME&lt;/code&gt;, making it easier to handle temporal values efficiently and effectively.&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>database</category>
      <category>data</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>What I Should know About Logging In PHP</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sat, 23 Mar 2024 13:17:18 +0000</pubDate>
      <link>https://forem.com/salmazz/what-i-should-know-about-logging-in-php-5gb4</link>
      <guid>https://forem.com/salmazz/what-i-should-know-about-logging-in-php-5gb4</guid>
      <description>&lt;p&gt;To effectively utilize PHP logging, there are several key concepts and practices you should be familiar with. These include understanding the purpose of logging, knowing the different logging levels, understanding how to configure and use PHP's built-in logging functions, and being aware of popular logging libraries like Monolog. Here's a breakdown of what you should know:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Purpose of Logging
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Debugging&lt;/strong&gt;: Logging helps in identifying and fixing bugs by recording events that happen during the execution of a program.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitoring&lt;/strong&gt;: It allows you to monitor the performance and behavior of your application in real time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit Trails&lt;/strong&gt;: Logs can serve as a record of what happened, when, and in what order.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Logging Levels
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Different Severities&lt;/strong&gt;: PHP supports various error levels, from &lt;code&gt;E_ERROR&lt;/code&gt; (fatal run-time errors) to &lt;code&gt;E_NOTICE&lt;/code&gt; (non-critical errors), &lt;code&gt;E_WARNING&lt;/code&gt; (run-time warnings), and others.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom Error Levels&lt;/strong&gt;: You can also define custom error levels using &lt;code&gt;E_USER_*&lt;/code&gt; constants.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Built-in PHP Logging Functions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;error_log()&lt;/code&gt;&lt;/strong&gt;: The primary function to log errors. It can send errors to the server's error log, a custom file, or a remote destination.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;trigger_error()&lt;/code&gt;&lt;/strong&gt;: Useful for generating user-level error messages, allowing you to specify an error level.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;syslog()&lt;/code&gt;&lt;/strong&gt;: For sending messages to the system logger.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. PHP Configuration for Logging
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;php.ini&lt;/code&gt; Settings&lt;/strong&gt;: PHP's behavior with errors and logging is configured in the &lt;code&gt;php.ini&lt;/code&gt; file. Key settings include &lt;code&gt;error_reporting&lt;/code&gt;, &lt;code&gt;display_errors&lt;/code&gt;, &lt;code&gt;log_errors&lt;/code&gt;, and &lt;code&gt;error_log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Configuration&lt;/strong&gt;: You can also set error reporting levels dynamically using the &lt;code&gt;error_reporting()&lt;/code&gt; function in your scripts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Logging Best Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Granular Control&lt;/strong&gt;: Use different logging levels to control the granularity of the information logged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sensitive Data&lt;/strong&gt;: Be cautious not to log sensitive information such as passwords or personal data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance&lt;/strong&gt;: Excessive logging can impact performance; ensure logging is appropriately balanced.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Using Logging Libraries (like Monolog)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Monolog&lt;/strong&gt;: A popular PHP logging library that offers advanced features like multiple handlers (e.g., to send logs to files, sockets, inboxes, databases, etc.) and processors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration&lt;/strong&gt;: Monolog can be easily integrated with various PHP frameworks, including Laravel and Symfony.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Logging in Different Environments
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Development vs. Production&lt;/strong&gt;: In a development environment, you might want more verbose logging, while in production, you would typically restrict this to critical errors only.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. Analyzing and Managing Logs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Log Analysis&lt;/strong&gt;: Regularly analyze logs for any signs of errors or unusual activity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log Rotation&lt;/strong&gt;: Implement log rotation to manage log file sizes and archival.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  9. Security Considerations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Access Control&lt;/strong&gt;: Ensure logs are securely stored and only accessible to authorized personnel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Disclosure&lt;/strong&gt;: Be cautious about revealing too much information in error messages that could be seen by end users.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By understanding these aspects of PHP logging, you can more effectively monitor and troubleshoot your PHP applications, leading to improved reliability and performance.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How Tables and indexes stored on Disk</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Mon, 04 Mar 2024 18:11:01 +0000</pubDate>
      <link>https://forem.com/salmazz/how-tables-and-indexes-stored-on-disk-4il5</link>
      <guid>https://forem.com/salmazz/how-tables-and-indexes-stored-on-disk-4il5</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This article delves into the structured manner in which tables and indexes are stored on disks in database systems. This understanding is pivotal for database optimization, impacting the efficiency of data access and manipulation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tables Storage
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Data Pages
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition&lt;/strong&gt;: Tables are stored in units known as "data pages" or "blocks."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content&lt;/strong&gt;: Each page typically holds a fixed number of rows. The exact number depends on the row size and page size, which is often 4 KB or 8 KB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Organization&lt;/strong&gt;: These pages are systematically arranged into a file or a set of files on the disk.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Example:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Consider a table with rows of 1 KB each. On a 4 KB page, up to four rows can be stored. If the table has 1000 rows, it would occupy at least 250 pages.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Row Format
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Storage Types&lt;/strong&gt;: Rows can be stored in fixed-length or variable-length formats.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Detail&lt;/strong&gt;: Each row consists of its column values.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Table Metadata
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Information Stored&lt;/strong&gt;: Details about the table structure, including column names, data types, and constraints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Location&lt;/strong&gt;: This information is usually stored in a system catalog or a metadata table.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  File Organization
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Types&lt;/strong&gt;:

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Heap&lt;/strong&gt;: An unordered storage of rows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clustered Index&lt;/strong&gt;: Rows are stored in the order of the primary key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Partitioned&lt;/strong&gt;: The table is divided into smaller, more manageable segments.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Indexes Storage
&lt;/h2&gt;

&lt;h4&gt;
  
  
  B-tree Indexes
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Structure&lt;/strong&gt;: A balanced tree consisting of root, internal, and leaf nodes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function&lt;/strong&gt;: Leaf nodes contain index entries with a key value and a pointer to the corresponding row.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commonality&lt;/strong&gt;: This is the most commonly used index structure.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Bitmap Indexes
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism&lt;/strong&gt;: Uses a bitmap for each key to indicate the presence or absence of a value.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency&lt;/strong&gt;: Particularly effective for columns with a low number of distinct values.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Hash Indexes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Function&lt;/strong&gt;: Utilizes a hash function to create a hash value for each key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Purpose&lt;/strong&gt;: These hash values facilitate quick data location during searches.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Index Metadata
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Content&lt;/strong&gt;: Information about the index, like indexed columns and index type.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage&lt;/strong&gt;: Stored in the system catalog, similar to table metadata.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Storage
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Separation&lt;/strong&gt;: Indexes are stored separately from the table data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extent&lt;/strong&gt;: They may cover multiple pages and files, varying in size.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Physical Storage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Disk Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Medium&lt;/strong&gt;: Both tables and indexes are stored as files on the disk.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  File System or Raw Devices
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Management&lt;/strong&gt;: These files might be managed by the file system or stored on raw devices, depending on the DBMS.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  I/O Operations
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DBMS Role&lt;/strong&gt;: The DBMS handles read/write operations, focusing on minimizing disk I/O, caching, and maintaining ACID properties.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Understanding the storage mechanisms of tables and indexes on disk is critical for optimizing database performance. This knowledge aids in making informed decisions about data organization and access strategies.&lt;/p&gt;

</description>
      <category>database</category>
      <category>dataengineering</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>Beyond the Basics: Leveraging ACID for Advanced Database Management</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sat, 24 Feb 2024 15:01:52 +0000</pubDate>
      <link>https://forem.com/salmazz/beyond-the-basics-leveraging-acid-for-advanced-database-management-gep</link>
      <guid>https://forem.com/salmazz/beyond-the-basics-leveraging-acid-for-advanced-database-management-gep</guid>
      <description>&lt;p&gt;In the heart of every database lies a set of principles known as ACID. These principles, standing for Atomicity, Consistency, Isolation, and Durability, act as the guardians of data integrity and reliability, ensuring that your transactions are executed seamlessly and accurately. Whether it's a financial transfer, an online purchase, or a simple data update, ACID ensures the smooth flow of information while safeguarding its consistency and security.&lt;/p&gt;

&lt;h2&gt;
  
  
  Atomicity: All or Nothing
&lt;/h2&gt;

&lt;p&gt;Imagine transferring funds between accounts. ACID's atomicity principle dictates that either the entire transaction (debiting one account and crediting another) happens successfully, or none of it does. This prevents incomplete transactions and ensures data consistency.&lt;/p&gt;

&lt;h2&gt;
  
  
  Consistency: Maintaining Harmony
&lt;/h2&gt;

&lt;p&gt;Think of a database as a symphony. ACID's consistency principle ensures that the data within the database adheres to its predefined rules and constraints before and after each transaction. This keeps the information accurate and reliable, like a well-tuned orchestra playing in perfect harmony.&lt;/p&gt;

&lt;h2&gt;
  
  
  Isolation: No Interference Allowed
&lt;/h2&gt;

&lt;p&gt;Imagine two users simultaneously editing the same document. ACID's isolation principle guarantees that each user operates in their own independent space, unaffected by the other's actions. This prevents conflicting changes and maintains data integrity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Durability: The Imprint of Change
&lt;/h2&gt;

&lt;p&gt;Picture a power outage during a crucial transaction. ACID's durability principle ensures that even in case of system failures, the changes made to the database are permanently recorded. This protects valuable data from being lost in the digital ether.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why ACID Matters:
&lt;/h2&gt;

&lt;p&gt;ACID principles are the foundation of secure and reliable database systems. They guarantee:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Data Integrity: Eliminates inconsistencies and corruption, ensuring accurate information.&lt;br&gt;
Transaction Reliability: Ensures transactions are completed successfully or not at all, preventing data loss.&lt;br&gt;
System Resilience: Protects data from system failures and ensures its continued availability.&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Applications of ACID:&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;ACID plays a vital role in various applications, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    Financial Transactions: Guaranteeing secure and accurate money transfers.&lt;/li&gt;
&lt;li&gt;    Inventory Management: Maintaining accurate stock levels and preventing overselling.&lt;/li&gt;
&lt;li&gt;    E-commerce Platforms: Ensuring smooth and reliable online purchases.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;ACID principles are the unsung heroes of the database world, silently ensuring the integrity and reliability of your data. By understanding these principles, you gain a deeper appreciation for the intricate mechanisms safeguarding the valuable information at the heart of your digital systems.&lt;/p&gt;

</description>
      <category>database</category>
      <category>development</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Navigating Web Server Technologies: Apache, Nginx</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Wed, 21 Feb 2024 20:21:56 +0000</pubDate>
      <link>https://forem.com/salmazz/navigating-web-server-technologies-apache-nginx-and-hosting-options-2po1</link>
      <guid>https://forem.com/salmazz/navigating-web-server-technologies-apache-nginx-and-hosting-options-2po1</guid>
      <description>&lt;h1&gt;
  
  
  Understanding Web Server Technologies: A Developer's Guide to Apache, Nginx, and Hosting Solutions
&lt;/h1&gt;

&lt;p&gt;Web server technologies are a cornerstone of web development and understanding them is crucial for developers. This guide explores Apache, Nginx, and various hosting options, providing insights that can help developers make informed decisions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web Servers Demystified
&lt;/h2&gt;

&lt;p&gt;Web servers are essential for serving web content over the internet. They handle requests from clients, typically web browsers, and deliver content like HTML, images, and files. Key players in this domain include Apache HTTP Server, Nginx, Microsoft IIS, LiteSpeed, Apache Tomcat, and Node.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selecting a Web Server for PHP Laravel
&lt;/h2&gt;

&lt;p&gt;For PHP Laravel applications, Apache and Nginx stand out. Apache offers ease of configuration and is widely supported, making it a favorite for PHP applications. Nginx is ideal for handling high traffic efficiently but requires PHP-FPM for processing PHP scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web Server Setup on Mac and Windows
&lt;/h2&gt;

&lt;h3&gt;
  
  
  For Mac Users:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Built-in Apache Server&lt;/strong&gt;: A convenient option for PHP projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MAMP&lt;/strong&gt;: User-friendly with Apache, MySQL, and PHP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker&lt;/strong&gt;: Ideal for creating isolated environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Homebrew&lt;/strong&gt;: Offers flexibility in installing various web servers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Valet&lt;/strong&gt;: Specifically designed for Laravel development.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;XAMPP&lt;/strong&gt;: A cross-platform solution for a local server environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  For Windows Users:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;XAMPP and WAMP&lt;/strong&gt;: Simple setups for Apache, MySQL, and PHP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MAMP&lt;/strong&gt;: A straightforward, cross-platform option.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker&lt;/strong&gt;: For advanced, customizable environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IIS&lt;/strong&gt;: Windows’ native web server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Laragon and Homestead&lt;/strong&gt;: Excellent for Laravel development.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Learning Apache and Nginx in Detail
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Mastering Apache:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Official Documentation&lt;/strong&gt;: Start with Apache's comprehensive guides.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Online Resources&lt;/strong&gt;: Utilize tutorials and courses for practical learning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Books&lt;/strong&gt;: Dive deep with resources like "Apache Cookbook."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice&lt;/strong&gt;: Set up and experiment with Apache locally.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community Engagement&lt;/strong&gt;: Join forums and discussions for real-world insights.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Understanding Nginx:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Official Documentation&lt;/strong&gt;: Essential for foundational knowledge.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Online Learning&lt;/strong&gt;: Explore tutorials and courses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hands-On Experience&lt;/strong&gt;: Practice with a local Nginx setup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stay Informed&lt;/strong&gt;: Follow blogs and articles for advanced tips.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tips for Both:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Project-Based Learning&lt;/strong&gt;: Implement your skills in real projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Networking Basics&lt;/strong&gt;: Complement your knowledge with networking fundamentals.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Continuous Learning&lt;/strong&gt;: Stay updated with the latest developments.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;This guide provides a comprehensive overview of web server technologies, focusing on Apache, Nginx, and hosting platforms. The journey in mastering these technologies lies in balancing theoretical knowledge with practical application, and adapting to the evolving web landscape. Whether you're setting up a server, choosing a hosting solution, or diving deep into server configurations, this guide aims to empower developers with the knowledge to make informed decisions.&lt;/p&gt;

</description>
      <category>apache</category>
      <category>nginx</category>
      <category>php</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Understanding Laravel Collections: `reject` vs. `map`</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sun, 10 Dec 2023 13:31:36 +0000</pubDate>
      <link>https://forem.com/salmazz/understanding-laravel-collections-reject-vs-map-2ak4</link>
      <guid>https://forem.com/salmazz/understanding-laravel-collections-reject-vs-map-2ak4</guid>
      <description>&lt;p&gt;*&lt;em&gt;Laravel Collections *&lt;/em&gt; provide a powerful and expressive way to work with arrays or sets of data. In this post, we'll explore two fundamental functions: &lt;code&gt;reject&lt;/code&gt; and &lt;code&gt;map&lt;/code&gt;. While both are essential tools in your Laravel toolkit, they serve distinct purposes in data manipulation.&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;reject&lt;/code&gt; Function:
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;reject&lt;/code&gt; function is your go-to tool for filtering out items from a collection based on a specified condition. It creates a new collection that excludes items for which the callback returns &lt;code&gt;true&lt;/code&gt;. Let's look at an 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;$collection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;collect&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;2&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;4&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;span class="nv"&gt;$filtered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$collection&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;reject&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;$item&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="nv"&gt;$item&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&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="c1"&gt;// Exclude even numbers&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nf"&gt;dd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$filtered&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// Output: [1, 3, 5]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we use &lt;code&gt;reject&lt;/code&gt; to create a new collection that excludes even numbers from the original collection.&lt;/p&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;map&lt;/code&gt; Function:
&lt;/h3&gt;

&lt;p&gt;On the flip side, the &lt;code&gt;map&lt;/code&gt; function is your ally when you need to transform each item in a collection using a callback. It creates a new collection with the results of applying the callback to each item. Here's an illustration:&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;$collection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;collect&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;2&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;4&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;span class="nv"&gt;$squared&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$collection&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;map&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;$item&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="nv"&gt;$item&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;$item&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Square each number&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nf"&gt;dd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$squared&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// Output: [1, 4, 9, 16, 25]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we use &lt;code&gt;map&lt;/code&gt; to create a new collection where each item is squared.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Differences:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;reject&lt;/code&gt;: Filters items based on a condition, excluding items that satisfy it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;map&lt;/code&gt;: Transforms items based on a callback, creating a new collection with the transformed values.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;reject&lt;/code&gt;: Returns a new collection with items that did not meet the specified condition.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;map&lt;/code&gt;: Returns a new collection with items transformed according to the provided callback.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Callback Return Value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;reject&lt;/code&gt;: Includes items for which the callback returns &lt;code&gt;false&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;map&lt;/code&gt;: Includes the results of applying the callback to each item.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In summary, while &lt;code&gt;reject&lt;/code&gt; is your tool for excluding items, &lt;code&gt;map&lt;/code&gt; is your friend for transforming them. Choose the right function based on your data manipulation needs.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>php</category>
      <category>programming</category>
      <category>development</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Breaking Down SQL Syntax Guide to Using Quotes</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sun, 12 Nov 2023 19:56:03 +0000</pubDate>
      <link>https://forem.com/salmazz/breaking-down-sql-syntax-guide-to-using-quotes-8ic</link>
      <guid>https://forem.com/salmazz/breaking-down-sql-syntax-guide-to-using-quotes-8ic</guid>
      <description>&lt;p&gt;In SQL, the use of quotes can vary based on the context and the specific SQL database system you are using. Here's a general guideline:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Double Quotes (")&lt;/strong&gt;: Typically used to enclose identifiers like table and column names. They are necessary if the identifier is a reserved keyword or contains special characters or spaces. For instance, &lt;code&gt;"Customers"&lt;/code&gt; or &lt;code&gt;"Order ID"&lt;/code&gt;. However, not all SQL databases require or allow double quotes for identifiers. For example, MySQL often uses backticks (`) instead of double quotes for this purpose.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Single Quotes (')&lt;/strong&gt;: Used for enclosing string literals, such as values you might insert into a table. For example, in a query like &lt;code&gt;INSERT INTO Customers (Name) VALUES ('John Doe');&lt;/code&gt;, 'John Doe' is a string literal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Backticks (`)&lt;/strong&gt;: Primarily used in MySQL to enclose table or column names. They serve a similar purpose to double quotes in other SQL databases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No Quotes&lt;/strong&gt;: If your identifiers (like table or column names) do not contain special characters, spaces, or are not reserved keywords, you often don't need to use any quotes. For example, &lt;code&gt;SELECT * FROM Customers&lt;/code&gt; is perfectly valid if "Customers" is a simple, non-reserved identifier.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here are some examples to illustrate the use of quotes in SQL queries across different scenarios and database systems:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Using Double Quotes for Identifiers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PostgreSQL / Standard SQL&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;  &lt;span class="k"&gt;SELECT&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;"age"&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="nv"&gt;"Users"&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;In this case, &lt;code&gt;"name"&lt;/code&gt; and &lt;code&gt;"age"&lt;/code&gt; might be the column names and &lt;code&gt;"Users"&lt;/code&gt; the table name. Double quotes are used because PostgreSQL adheres closely to the SQL standard, which recommends double quotes for identifiers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Using Single Quotes for String Literals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;General Example (Applicable to Most SQL Databases)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;  &lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;Customers&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;City&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&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;'New York'&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;Here, 'John Doe' and 'New York' are string literals representing values to be inserted into the columns &lt;code&gt;Name&lt;/code&gt; and &lt;code&gt;City&lt;/code&gt; of the &lt;code&gt;Customers&lt;/code&gt; table.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Using Backticks for Identifiers (MySQL Specific)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MySQL&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;  &lt;span class="k"&gt;SELECT&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;`age`&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="nv"&gt;`Users`&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;MySQL uses backticks to quote identifiers like table and column names. This is particularly useful if the identifier names are also reserved keywords or if they contain special characters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. No Quotes for Simple Identifiers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;General Example&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Users&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;If the table and column names don’t contain any special characters, spaces, or aren’t reserved keywords, you can use them without any quotes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Mixed Usage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;General Example&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="nv"&gt;"Employee Name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Employees&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="nv"&gt;"Employee Name"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'John Doe'&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;In this query, &lt;code&gt;"Employee Name"&lt;/code&gt; (an identifier) uses double quotes because it contains a space, while 'John Doe' (a string literal) uses single quotes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Always remember to check the documentation for the specific SQL database you are using, as these conventions can vary. For example, what works in PostgreSQL might not work exactly the same way in MySQL or Microsoft SQL Server.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Decoding PHP's Empty Value Functions: When to Use Which</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Tue, 07 Nov 2023 18:32:46 +0000</pubDate>
      <link>https://forem.com/salmazz/php-check-for-empty-values-vs-isnull-vs-isset-vs-isempty-46k4</link>
      <guid>https://forem.com/salmazz/php-check-for-empty-values-vs-isnull-vs-isset-vs-isempty-46k4</guid>
      <description>&lt;p&gt;In PHP, checking for empty values is a common operation, and there are several ways to do this. Understanding the differences between using &lt;code&gt;!&lt;/code&gt;, &lt;code&gt;is_null()&lt;/code&gt;, and &lt;code&gt;isset()&lt;/code&gt; is important, as they each check for different conditions:&lt;/p&gt;

&lt;h3&gt;
  
  
  Using &lt;code&gt;!&lt;/code&gt; (Not Operator)
&lt;/h3&gt;

&lt;p&gt;The not operator &lt;code&gt;!&lt;/code&gt; is used to check if a value is &lt;code&gt;false&lt;/code&gt;. In PHP, several types of values are considered as "falsy" when used in a boolean context:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The boolean &lt;code&gt;false&lt;/code&gt; itself&lt;/li&gt;
&lt;li&gt;The integer &lt;code&gt;0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The float &lt;code&gt;0.0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The empty string &lt;code&gt;''&lt;/code&gt; and the string &lt;code&gt;"0"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;An array with zero elements&lt;/li&gt;
&lt;li&gt;The special type &lt;code&gt;NULL&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;SimpleXML objects created from empty tags&lt;/li&gt;
&lt;/ul&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="nv"&gt;$value&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$value&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="s1"&gt;'The value is considered empty.'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// This will output: The value is considered empty.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using &lt;code&gt;is_null()&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;is_null()&lt;/code&gt; function checks if a variable is exactly &lt;code&gt;NULL&lt;/code&gt;. It does not check for any other "empty" values like &lt;code&gt;''&lt;/code&gt; (empty string) or &lt;code&gt;0&lt;/code&gt; (zero as an integer or float), it only returns &lt;code&gt;true&lt;/code&gt; if the variable is &lt;code&gt;NULL&lt;/code&gt;.&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="nv"&gt;$value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;is_null&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$value&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="s1"&gt;'The value is NULL.'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// This will output: The value is NULL.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using &lt;code&gt;isset()&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;isset()&lt;/code&gt; function checks if a variable is set and is not &lt;code&gt;NULL&lt;/code&gt;. If a variable has been unset using &lt;code&gt;unset()&lt;/code&gt;, has not been assigned a value, or is assigned the value &lt;code&gt;NULL&lt;/code&gt;, then &lt;code&gt;isset()&lt;/code&gt; will return &lt;code&gt;false&lt;/code&gt;. It is often used to check if array keys or object properties exist and are not &lt;code&gt;NULL&lt;/code&gt;.&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="nv"&gt;$value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$value&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="s1"&gt;'This will not be printed.'&lt;/span&gt;&lt;span class="p"&gt;;&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="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'The variable is not set or is NULL.'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// This will output: The variable is not set or is NULL.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;isset()&lt;/code&gt; also returns &lt;code&gt;true&lt;/code&gt; for variables set to any value other than &lt;code&gt;NULL&lt;/code&gt;, including &lt;code&gt;false&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt;, or an empty string &lt;code&gt;''&lt;/code&gt;. However, &lt;code&gt;isset()&lt;/code&gt; can be used to check for the existence of a variable while &lt;code&gt;is_null()&lt;/code&gt; and the not operator can only be used on variables that are already set.&lt;br&gt;
The &lt;code&gt;empty()&lt;/code&gt; function in PHP is used to determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value is one of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;""&lt;/code&gt; (an empty string)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;0&lt;/code&gt; (0 as an integer)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;0.0&lt;/code&gt; (0 as a float)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"0"&lt;/code&gt; (0 as a string)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;null&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;false&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;An array with zero elements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's important to note that &lt;code&gt;empty()&lt;/code&gt; is a bit more comprehensive in its checks compared to using the &lt;code&gt;!&lt;/code&gt; operator. While the &lt;code&gt;!&lt;/code&gt; operator will return &lt;code&gt;true&lt;/code&gt; for any falsy value, &lt;code&gt;empty()&lt;/code&gt; will also return &lt;code&gt;true&lt;/code&gt; for unset variables (variables that have not been declared), which the &lt;code&gt;!&lt;/code&gt; operator will not do, since using &lt;code&gt;!&lt;/code&gt; on an unset variable will raise a notice.&lt;/p&gt;

&lt;p&gt;Here's an example illustrating the use of &lt;code&gt;empty()&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="nv"&gt;$value&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$value&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="s1"&gt;'The value is considered empty by empty().'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// This will output: The value is considered empty by empty().&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$value&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="s1"&gt;'The value is considered empty by ! operator.'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// This will also output: The value is considered empty by ! operator.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's important to use &lt;code&gt;empty()&lt;/code&gt; when you expect the variable might not be set at all, as it won't generate a warning or notice, whereas &lt;code&gt;!&lt;/code&gt; will if you use it on a variable that hasn't been declared.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;empty()&lt;/code&gt; is particularly useful when you need to check for the presence and non-empty value of a variable (like user input or a potentially missing array key) in a single operation.&lt;/p&gt;

&lt;p&gt;Here's a comparison example with &lt;code&gt;isset()&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="nv"&gt;$value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// This will return true because $value is an empty string.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$value&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="s1"&gt;'The value is empty.'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// This will return false because $value is set.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$value&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="s1"&gt;'The variable is not set.'&lt;/span&gt;&lt;span class="p"&gt;;&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="k"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'The variable is set.'&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;In the above example, even though &lt;code&gt;$value&lt;/code&gt; is an empty string and considered "empty", it is still set, so &lt;code&gt;isset()&lt;/code&gt; will return &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  More Examples :
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
 Here are four examples each for &lt;code&gt;empty()&lt;/code&gt;, &lt;code&gt;!&lt;/code&gt; (Not operator), &lt;code&gt;is_null()&lt;/code&gt;, and &lt;code&gt;isset()&lt;/code&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;empty()&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example 1: Variable is an empty string&lt;/span&gt;
&lt;span class="nv"&gt;$var1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="k"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'empty'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not empty'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'empty'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 2: Variable is zero as an integer&lt;/span&gt;
&lt;span class="nv"&gt;$var2&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="k"&gt;echo&lt;/span&gt; &lt;span class="k"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'empty'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not empty'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'empty'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 3: Variable is false&lt;/span&gt;
&lt;span class="nv"&gt;$var3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="k"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'empty'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not empty'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'empty'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 4: Variable is an empty array&lt;/span&gt;
&lt;span class="nv"&gt;$var4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="k"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'empty'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not empty'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'empty'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;!&lt;/code&gt; (Not operator)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example 1: Variable is an empty string&lt;/span&gt;
&lt;span class="nv"&gt;$var1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$var1&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'true'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'false'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'true'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 2: Variable is zero as an integer&lt;/span&gt;
&lt;span class="nv"&gt;$var2&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="k"&gt;echo&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$var2&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'true'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'false'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'true'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 3: Variable is false&lt;/span&gt;
&lt;span class="nv"&gt;$var3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$var3&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'true'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'false'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'true'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 4: Variable is null&lt;/span&gt;
&lt;span class="nv"&gt;$var4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$var4&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'true'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'false'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'true'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;is_null()&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example 1: Variable is explicitly set to null&lt;/span&gt;
&lt;span class="nv"&gt;$var1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nb"&gt;is_null&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'null'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not null'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'null'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 2: Variable has not been set at all&lt;/span&gt;
&lt;span class="k"&gt;unset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Assuming $var2 was set before&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nb"&gt;is_null&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'null'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not null'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'null'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 3: Variable is an empty string (not null)&lt;/span&gt;
&lt;span class="nv"&gt;$var3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nb"&gt;is_null&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'null'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not null'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'not null'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 4: Variable is zero (not null)&lt;/span&gt;
&lt;span class="nv"&gt;$var4&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="k"&gt;echo&lt;/span&gt; &lt;span class="nb"&gt;is_null&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'null'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not null'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'not null'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;isset()&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example 1: Variable is set to non-null value&lt;/span&gt;
&lt;span class="nv"&gt;$var1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'set'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not set'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'set'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 2: Variable is set to null (therefore not set)&lt;/span&gt;
&lt;span class="nv"&gt;$var2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'set'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not set'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'not set'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 3: Variable is set to an empty array&lt;/span&gt;
&lt;span class="nv"&gt;$var3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'set'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not set'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'set'&lt;/span&gt;

&lt;span class="c1"&gt;// Example 4: Variable has not been set at all&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$var4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'set'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'not set'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Outputs 'not set'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In summary:&lt;br&gt;
Each function has its specific use case: empty() checks if the variable is considered "empty" in a broader sense; ! checks for "falsey" values; is_null() checks if the variable is null; and isset() checks if a variable is set and not null.&lt;/p&gt;

</description>
      <category>php</category>
      <category>backend</category>
      <category>programming</category>
      <category>functions</category>
    </item>
    <item>
      <title>Docker , Docker Compose Docker Swarm Vs Kubernetes</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sun, 25 Dec 2022 20:51:41 +0000</pubDate>
      <link>https://forem.com/salmazz/docker-docker-compose-docker-swarm-vs-kubernetes-2880</link>
      <guid>https://forem.com/salmazz/docker-docker-compose-docker-swarm-vs-kubernetes-2880</guid>
      <description>&lt;p&gt;&lt;strong&gt;Docker&lt;/strong&gt; is the core technology used for containers and can deploy single containerized applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  When do we use docker ?
&lt;/h3&gt;

&lt;p&gt;when you want to deploy a single (network accessible) container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker Compose&lt;/strong&gt; is used for configuring and starting multiple Docker containers on the same host a single host machine.&lt;br&gt;
&lt;em&gt;so you don't have to start each container separately&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;And Used for running multiple containers as a single service. Each Of the containers here run in isolation but can interact with each other when required.&lt;/p&gt;

&lt;h4&gt;
  
  
  When do we use docker compose?
&lt;/h4&gt;

&lt;p&gt;when you want to deploy multiple containers to a single host from within a single YAML . &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker swarm&lt;/strong&gt; is a container orchestration tool that allows you to run and connect containers on multiple hosts.&lt;/p&gt;

&lt;p&gt;Docker swarm can do tasks like :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scaling&lt;/li&gt;
&lt;li&gt;Start a new container when one crashes &lt;/li&gt;
&lt;li&gt;Networking containers and many more &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  When do we use docker swarm ?
&lt;/h4&gt;

&lt;p&gt;when you want to deploy a cluster of docker nodes (multiple hosts for a simple , scalable application &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kubernetes&lt;/strong&gt; known as "&lt;strong&gt;K8s&lt;/strong&gt;"  is a container orchestration tool that is similar to Docker swarm, but has a wider appeal due to its ease of automation and ability to handle higher demand.&lt;/p&gt;

&lt;p&gt;And Also our usual question &lt;/p&gt;

&lt;h4&gt;
  
  
  When do we use Kubernetes ?
&lt;/h4&gt;

&lt;p&gt;when you need to manage a large deployment of scalable , automated containers.&lt;/p&gt;

&lt;p&gt;In The end, it is just a definition for beginners and when u want to make a quick review before the interview hope it is useful! &lt;/p&gt;

&lt;p&gt;Wait for me for new Posts&lt;/p&gt;

</description>
    </item>
    <item>
      <title>VS Code Extensions for PHP Laravel Developer</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sat, 16 Apr 2022 04:02:18 +0000</pubDate>
      <link>https://forem.com/salmazz/vs-code-extensions-for-php-laravel-developer-305c</link>
      <guid>https://forem.com/salmazz/vs-code-extensions-for-php-laravel-developer-305c</guid>
      <description>&lt;p&gt;Hola Developers  !&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VS code&lt;/strong&gt; is the free alternative to *&lt;em&gt;phpstorm *&lt;/em&gt; and there is more than one extension that facilitates the code process and is characterized by being light, fast and flexible&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel-blade" rel="noopener noreferrer"&gt;Laravel Blade Snippet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Laravel blade snippets and syntax highlight support for Visual Studio Code.&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.amazonaws.com%2Fuploads%2Farticles%2Fjzqfd5c9sqka4vtp5vt5.gif" 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%2Fjzqfd5c9sqka4vtp5vt5.gif" alt="Image description" width="700" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel5-snippets" rel="noopener noreferrer"&gt;Laravel Snippets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Laravel snippets extension for Visual Studio Code (Support Laravel 5 and above version).&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.amazonaws.com%2Fuploads%2Farticles%2Ffc4g4ds4v24cj7etv6wj.gif" 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%2Ffc4g4ds4v24cj7etv6wj.gif" alt="Image description" width="700" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=codingyu.laravel-goto-view" rel="noopener noreferrer"&gt;Laravel goto view&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Click into to the name of the view in the controller &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.amazonaws.com%2Fuploads%2Farticles%2F9eju9vdc2u8o14c4mekm.gif" 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%2F9eju9vdc2u8o14c4mekm.gif" alt="Image description" width="720" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=amiralizadeh9480.laravel-extra-intellisense" rel="noopener noreferrer"&gt;Laravel Extra Intellisense&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This extension provides Laravel routes, views and ... autocomplete for VSCode.&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.amazonaws.com%2Fuploads%2Farticles%2Fs5q51g4jite2sc48m45e.gif" 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%2Fs5q51g4jite2sc48m45e.gif" alt="Image description" width="800" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=ahinkle.laravel-model-snippets" rel="noopener noreferrer"&gt;Laravel Model Snippets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Improve your workflow with Laravel Model Snippets. Start with Model:: then the shortcut of what you are looking for within your model.&lt;/p&gt;

&lt;p&gt;For example, Model::d will return the muted dates attribute:&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.amazonaws.com%2Fuploads%2Farticles%2Fk1j6cipru3at1v4kbupx.gif" 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%2Fk1j6cipru3at1v4kbupx.gif" alt="Image description" width="800" height="648"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;PHP code intelligence for Visual Studio Code.&lt;/p&gt;

&lt;p&gt;Intelephense is a high performance PHP language server packed full of essential features for productive PHP development.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=MehediDracula.php-namespace-resolver" rel="noopener noreferrer"&gt;PHP Namespace Resolver&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PHP Namespace Resolver can import and expand your class. You can also sort your imported classes by line length or in alphabetical order.&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.amazonaws.com%2Fuploads%2Farticles%2Fa3ivsjvcda42t6qamgrv.gif" 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%2Fa3ivsjvcda42t6qamgrv.gif" alt="Image description" width="1276" height="743"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=MehediDracula.php-constructor" rel="noopener noreferrer"&gt;PHP Constructor&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PHP Constructor can initialize constructor properties like insert_php_constructor_property command of SublimePHPCompanion.&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.amazonaws.com%2Fuploads%2Farticles%2Fj9i2xqskyru1zlz1zx9h.gif" 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%2Fj9i2xqskyru1zlz1zx9h.gif" alt="Image description" width="800" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tools To front end what interact with php laravel :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=octref.vetur" rel="noopener noreferrer"&gt;Vetur&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vue tooling for VS Code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss" rel="noopener noreferrer"&gt;Tailwind CSS IntelliSense Preview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Intelligent Tailwind CSS tooling for VS Code&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.amazonaws.com%2Fuploads%2Farticles%2Fj2sjderu40ktjz8wlthl.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%2Fj2sjderu40ktjz8wlthl.png" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Extension to make our code more beautiful and easier :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=2gua.rainbow-brackets&amp;amp;ssr=false#review-details" rel="noopener noreferrer"&gt; Rainbow Brackets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Provide rainbow colors for the round brackets, the square brackets and the squiggly brackets. This is particularly useful for Lisp or Clojure programmers, and of course, JavaScript, and other programmers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-close-tag" rel="noopener noreferrer"&gt;Auto Close Tag&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Automatically add HTML/XML close tag, same as Visual Studio IDE or Sublime Text does.&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.amazonaws.com%2Fuploads%2Farticles%2Fyh6e2jyhar9g1ln3vk3y.gif" 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%2Fyh6e2jyhar9g1ln3vk3y.gif" alt="Image description" width="1440" height="938"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Nice Themes !
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=DaltonMenezes.aura-theme" rel="noopener noreferrer"&gt;Aura Theme&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; A beautiful dark theme with four variants for Visual Studio Code. Two of these variants are focused on long-term work without &lt;br&gt;
causing any discomfort to the eyes.&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.amazonaws.com%2Fuploads%2Farticles%2Fmakwrlrna3pmpp2f5wpi.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%2Fmakwrlrna3pmpp2f5wpi.png" alt="Image description" width="800" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the end, I gave all the additions I know and considered useful. If there is more, you can add them in the comments. Thank you&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>programming</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Laravel With dynamic columns Translatable and Multi Lang in slug</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Fri, 04 Feb 2022 01:30:23 +0000</pubDate>
      <link>https://forem.com/salmazz/laravel-with-dynamic-columns-translatable-and-multi-lang-in-slug-416f</link>
      <guid>https://forem.com/salmazz/laravel-with-dynamic-columns-translatable-and-multi-lang-in-slug-416f</guid>
      <description>&lt;h2&gt;
  
  
  Aloha There !
&lt;/h2&gt;

&lt;p&gt;in this tutorial&lt;br&gt;
Use this package to make transtable columns dynamic and make slug transtable because it so useful in SEO &lt;br&gt;
We are using this two packages :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/spatie/laravel-translatable" rel="noopener noreferrer"&gt;https://github.com/spatie/laravel-translatable&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/spatie/laravel-sluggable" rel="noopener noreferrer"&gt;https://github.com/spatie/laravel-sluggable&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This package provides to us To make the column contain many lang without need to make 3 or 4 columns  to one lang &lt;br&gt;
as example If we have title in arabic , english and Spanish &lt;br&gt;
we will have &lt;br&gt;
title_ar&lt;br&gt;
title_en&lt;br&gt;
title_es &lt;br&gt;
another columns if we make have column called description &lt;br&gt;
it is not good to performance , more data in db and not perfectly when get data &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/spatie/laravel-translatable" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;install this package with this &lt;br&gt;
&lt;code&gt;composer require spatie/laravel-translatable&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
If you want to have another fallback_locale than the app fallback locale (see config/app.php), you could publish the config file:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan vendor:publish --provider="Spatie\Translatable\TranslatableServiceProvider"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;in our modal add this trait &lt;br&gt;
&lt;code&gt;use HasTranslations;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
then make install to sluggable package &lt;br&gt;
from there &lt;br&gt;
&lt;code&gt;composer require spatie/laravel-sluggable&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and add this trait in modal &lt;/p&gt;

&lt;p&gt;&lt;code&gt;HasTranslatableSlug&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and put every column who have translate in this variable in this like it &lt;/p&gt;

&lt;p&gt;&lt;code&gt;public $translatable = ['name', 'slug'];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add This function in modal &lt;br&gt;
this function create slug and when we reterive the slug with two langague &lt;br&gt;
put&lt;br&gt;
&lt;code&gt;usingLanguage(false) &lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
     * Get the options for generating the slug.
     */
    public function getSlugOptions() : SlugOptions
    {
        return SlugOptions::createWithLocales(['en', 'ar'])
            -&amp;gt;generateSlugsFrom(function($model, $locale) {
                return "{$model-&amp;gt;name}";
            })
            -&amp;gt;saveSlugsTo('slug')
            -&amp;gt;usingLanguage(false);
    }

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

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;the final view for modal &lt;br&gt;
*&lt;/em&gt;&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.amazonaws.com%2Fuploads%2Farticles%2Frs8dvl9egw1puud7tdb6.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%2Frs8dvl9egw1puud7tdb6.png" alt="Image description" width="746" height="826"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in the migration we create the column in this way &lt;br&gt;
&lt;code&gt;$table-&amp;gt;json('name');&lt;br&gt;
            $table-&amp;gt;json('slug');&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
*&lt;em&gt;in create form &lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!doctype html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="ie=edge"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;a href="{{route('posts.create')}}"&amp;gt;Create&amp;lt;/a&amp;gt;
&amp;lt;form action="{{route('posts.store')}}" method="post"&amp;gt;
    @csrf
    &amp;lt;input type="text" name="name[ar]"&amp;gt;
    &amp;lt;input type="text" name="name[en]"&amp;gt;

    &amp;lt;input type="submit" value="Save"&amp;gt;
&amp;lt;/form&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;in web.php &lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Route::group(['prefix' =&amp;gt; LaravelLocalization::setLocale()], function()
{
    Route::get('/', function () {
        return view('welcome');
    });

       Route::resource('/posts',PostController::class)-&amp;gt;except('delete','update');

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

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;in Post Controller&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
     * 
     * Get All posts
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
     */
    public function index()
    {
        $posts = Post::all();
        return view('index', compact('posts'));
    }


    /**
     * Create new post 
     * 
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
     */
    public function create()
    {
        return view('create');
    }

    /**
     * Store new post 
     * 
     * @param Request $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function store(Request $request)
    {
        $post = Post::create($request-&amp;gt;all());
        return redirect()-&amp;gt;route('posts.index');
    }

    /**
     * Show post
     * @param $slug
     * @return \Illuminate\Http\JsonResponse
     */
    public function show($slug)
    {
        $post = Post::where('slug','like','%"'.$slug.'"%')-&amp;gt;first();
        return response()-&amp;gt;json($post);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You Can see all of  this code in this repo &lt;br&gt;
&lt;a href="https://github.com/salmazz/Multi-Langague-Example-Laravel-" rel="noopener noreferrer"&gt;https://github.com/salmazz/Multi-Langague-Example-Laravel-&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If u have any question please contact to me ! &lt;br&gt;
hope it will be useful thank u &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
