<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jobayer Mojumder</title>
    <description>The latest articles on DEV Community by Jobayer Mojumder (@jobayer).</description>
    <link>https://dev.to/jobayer</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%2F1153300%2F313299b7-5d5f-4d72-b7c2-466fbf20d856.jpeg</url>
      <title>DEV Community: Jobayer Mojumder</title>
      <link>https://dev.to/jobayer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jobayer"/>
    <language>en</language>
    <item>
      <title>Exploring Map, Reduce, and Filter Functions in PHP</title>
      <dc:creator>Jobayer Mojumder</dc:creator>
      <pubDate>Wed, 08 May 2024 09:32:41 +0000</pubDate>
      <link>https://dev.to/jobayer/exploring-map-reduce-and-filter-functions-in-php-19m9</link>
      <guid>https://dev.to/jobayer/exploring-map-reduce-and-filter-functions-in-php-19m9</guid>
      <description>&lt;p&gt;The map, reduce, and filter functions are fundamental tools for efficient data manipulation. These functions allow developers to write more readable, maintainable, and concise code. Let’s delve deeper into each of these functions and explore how they can optimize data processing tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Map Function
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;array_map()&lt;/code&gt; function in PHP is a powerful utility that applies a callback function to each element in an array and returns a new array containing the elements modified by the callback. This function is invaluable when you need to transform array elements systematically.&lt;/p&gt;

&lt;h4&gt;
  
  
  Use Cases:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;- Transformation:&lt;/strong&gt; Applying operations like mathematical functions, string operations, or complex data transformations.&lt;br&gt;
&lt;strong&gt;- Batch Processing:&lt;/strong&gt; Easily modify all records retrieved from a database before displaying or processing further.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;p&gt;Suppose you want to adjust the prices in an array by applying a 10% increase:&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;$prices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nv"&gt;$adjustedPrices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;array_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;$price&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;$price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;1.10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nv"&gt;$prices&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;print_r&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$adjustedPrices&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;Output:&lt;/strong&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="k"&gt;Array&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;110&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;220&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;330&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Reduce Function
&lt;/h3&gt;

&lt;p&gt;While &lt;code&gt;array_map()&lt;/code&gt; applies a transformation to individual elements, &lt;code&gt;array_reduce()&lt;/code&gt; takes an array and reduces it to a single value using a callback function. This function is ideal for performing cumulative operations on an array.&lt;/p&gt;

&lt;h4&gt;
  
  
  Use Cases:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;- Summation or Product:&lt;/strong&gt; Calculate totals or products of array values.&lt;br&gt;
&lt;strong&gt;- Data Compression:&lt;/strong&gt; Aggregate complex data into a simpler format or value.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;p&gt;To calculate the total of the adjusted prices array:&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;$totalPrice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;array_reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$adjustedPrices&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;$carry&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;$carry&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="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$totalPrice&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;Output:&lt;/strong&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="mi"&gt;660&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Filter Function
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;array_filter()&lt;/code&gt; function is used to remove elements from an array that do not meet a specified condition. It provides a concise way to quickly filter out unwanted values based on custom criteria.&lt;/p&gt;

&lt;h4&gt;
  
  
  Use Cases:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;- Condition-based Filtering:&lt;/strong&gt; Remove elements that don’t match certain criteria.&lt;br&gt;
&lt;strong&gt;- Data Cleansing:&lt;/strong&gt; Omit invalid, empty, or undesired data from an array.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;p&gt;Filtering to keep only even numbers from an array of integers:&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;$numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="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="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nv"&gt;$evenNumbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;array_filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$numbers&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;$number&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;$number&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="p"&gt;});&lt;/span&gt;
&lt;span class="nb"&gt;print_r&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$evenNumbers&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;Output:&lt;/strong&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="k"&gt;Array&lt;/span&gt;
&lt;span class="p"&gt;(&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="o"&gt;=&amp;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="o"&gt;=&amp;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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These &lt;code&gt;array_map()&lt;/code&gt;, &lt;code&gt;array_reduce()&lt;/code&gt;, and &lt;code&gt;array_filter()&lt;/code&gt; functions are indispensable tools in the PHP programmer’s toolkit. They simplify the process of manipulating arrays and help maintain clean and efficient codebases. You can enhance code readability and performance by integrating these functions into your PHP development practices.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>php</category>
    </item>
    <item>
      <title>How to solve Unknown variable 'default-authentication-plugin' in Laradock</title>
      <dc:creator>Jobayer Mojumder</dc:creator>
      <pubDate>Thu, 02 May 2024 14:10:51 +0000</pubDate>
      <link>https://dev.to/jobayer/how-to-solve-unknown-variable-default-authentication-plugin-in-laradock-2pfo</link>
      <guid>https://dev.to/jobayer/how-to-solve-unknown-variable-default-authentication-plugin-in-laradock-2pfo</guid>
      <description>&lt;p&gt;In the latest version of MySQL, the previously common &lt;code&gt;mysql_native_password&lt;/code&gt; authentication plugin is no longer enabled by default. This change reflects an ongoing shift towards more secure authentication methods. If your applications or services require the &lt;code&gt;mysql_native_password&lt;/code&gt; plugin, you can reactivate it by modifying your server's startup configuration. Specifically, you can either pass the -&lt;code&gt;mysql-native-password=ON&lt;/code&gt; option when starting the MySQL server or by adding the line mysql_native_password=ON directly to the [mysqld] section of your MySQL configuration file. This adjustment will override the default settings and re-enable the plugin, allowing legacy applications that depend on this authentication method to continue operating without disruption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To ensure compatibility with older applications that rely on the traditional MySQL authentication method, it's necessary to make a slight adjustment in your MySQL configuration. Begin by removing the &lt;code&gt;default-authentication-plugin&lt;/code&gt; entry from your &lt;code&gt;mysql/my.cnf&lt;/code&gt; file. After removing it, you should explicitly add the entry &lt;code&gt;mysql_native_password=ON&lt;/code&gt; to the configuration.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgis1qyrs33zrnxori48p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgis1qyrs33zrnxori48p.png" alt="Code" width="800" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that rebuild your MySQL image by running &lt;code&gt;docker-compose build mysql&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://dev.mysql.com/doc/relnotes/mysql/8.4/en/news-8-4-0.html#:~:text=Important%20Change%3A%20The%20deprecated%20mysql_native_password%20authentication%20plugin%20is%20now%20disabled%20by%20default.%20It%20can%20be%20enabled%20by%20starting%20MySQL%20with%20the%20new%20%2D%2Dmysql%2Dnative%2Dpassword%3DON%20server%20option%2C%20or%20by%20adding%20mysql_native_password%3DON%20to%20the%20%5Bmysqld%5D%20section%20of%20your%20MySQL%20configuration%20file."&gt;https://dev.mysql.com/doc&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laradock</category>
      <category>mysql</category>
      <category>webdev</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Embracing Innovation: Best Practices for Adopting PHP 8.3</title>
      <dc:creator>Jobayer Mojumder</dc:creator>
      <pubDate>Tue, 30 Apr 2024 19:50:37 +0000</pubDate>
      <link>https://dev.to/jobayer/embracing-innovation-best-practices-for-adopting-php-83-1m8k</link>
      <guid>https://dev.to/jobayer/embracing-innovation-best-practices-for-adopting-php-83-1m8k</guid>
      <description>&lt;p&gt;PHP 8.3 is the latest milestone in the evolution of this ubiquitous server-side scripting language, known for powering everything from small websites to comprehensive web platforms. With significant enhancements that promise improved performance, better security, and streamlined development processes, PHP 8.3 is poised to set new standards in web development. This post aims to unpack the new features of PHP 8.3, recommend best practices for its adoption, and highlight its potential benefits for developers and businesses alike.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What’s New in PHP 8.3?&lt;/strong&gt;&lt;br&gt;
PHP 8.3 introduces several exciting features that enhance functionality and developer productivity:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Typed Class Constants: This new feature allows for the enforcement of data types on class constants, ensuring better code reliability.&lt;/li&gt;
&lt;li&gt;Dynamic Fetching of Class Constants and Enum Members: Simplifies how constants and enums are handled, allowing for more flexible code.&lt;/li&gt;
&lt;li&gt;JSON Validation Function (&lt;code&gt;json_validate()&lt;/code&gt;): Streamlines JSON data handling by validating against predefined schemas, thus reducing bugs related to bad data formats.&lt;/li&gt;
&lt;li&gt;Enhancements to the Random Extension: Introduces methods like &lt;code&gt;getBytesFromString()&lt;/code&gt; and &lt;code&gt;getFloat()&lt;/code&gt;, which provide more options for generating random data accurately and efficiently.&lt;/li&gt;
&lt;li&gt;Improved Error Handling in &lt;code&gt;unserialize()&lt;/code&gt;: This update enhances the robustness of PHP applications by changing how errors are handled during the unserialize process.&lt;/li&gt;
&lt;li&gt;An important highlight is the &lt;code&gt;#[Override]&lt;/code&gt; attribute, which ensures that method overrides are explicitly declared, preventing issues related to method mismatches in class hierarchies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Upgrading to PHP 8.3&lt;/strong&gt;&lt;br&gt;
Upgrading to PHP 8.3 is not just about accessing new features—it’s about making web applications faster, more secure, and easier to manage. Here are a few benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Performance Improvements: PHP 8.3 includes optimizations that reduce memory usage and increase execution speed.&lt;/li&gt;
&lt;li&gt;Security Enhancements: With each release, PHP improves its defenses against common security threats, making PHP 8.3 a smarter choice for developers serious about security.&lt;/li&gt;
&lt;li&gt;Streamlined Development: New features like the &lt;code&gt;json_validate()&lt;/code&gt; function and dynamic data type enhancements mean that developers can write more concise, maintainable, and error-free code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Practices for Upgrading to PHP 8.3&lt;/strong&gt;&lt;br&gt;
To take full advantage of PHP 8.3 without disrupting existing operations, consider the following best practices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Thorough Testing: Before fully implementing PHP 8.3, test your applications in a controlled staging environment to identify any incompatibilities or issues.&lt;/li&gt;
&lt;li&gt;Gradual Integration: Introduce PHP 8.3 features gradually into your production environment to minimize disruptions.&lt;/li&gt;
&lt;li&gt;Attention to Deprecations: Stay aware of deprecated features and refactor your codebase accordingly to ensure it remains compliant and secure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Compatibility Considerations&lt;/strong&gt;&lt;br&gt;
While PHP 8.3 is designed to be backward compatible with previous versions, it introduces changes that may affect existing applications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backward Compatibility Issues: Some older code may not function as expected due to tightened security measures or deprecated functionalities.&lt;/li&gt;
&lt;li&gt;Handling Breaking Changes: Review the official PHP migration guide for detailed information on changes and how to address them effectively.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Case Studies/Real-World Examples&lt;/strong&gt;&lt;br&gt;
Consider the hypothetical case of a tech startup that leveraged PHP 8.3’s new features to reduce their data processing times by 20%. By using the new &lt;code&gt;json_validate()&lt;/code&gt; function, they ensured that data integrity was maintained, which significantly reduced the occurrences of data-related errors in their application.&lt;/p&gt;

&lt;p&gt;PHP 8.3 represents a significant step forward for developers looking to push the boundaries of web technology. By upgrading, developers can ensure their applications run faster, are more secure, and are easier to maintain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Call to Action&lt;/strong&gt;&lt;br&gt;
Are you planning to upgrade to PHP 8.3, or have you already experienced its benefits? Share your thoughts and experiences in the comments below, or contact us for more information on how PHP 8.3 can be integrated into your projects.&lt;/p&gt;

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