<?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: Automata</title>
    <description>The latest articles on Forem by Automata (@automata).</description>
    <link>https://forem.com/automata</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%2F1107434%2Fad073eb5-432f-42a1-a8f9-3eeafb7e55ab.png</url>
      <title>Forem: Automata</title>
      <link>https://forem.com/automata</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/automata"/>
    <language>en</language>
    <item>
      <title>Install PHP 8.3 and config Apache in Ubuntu 22.04</title>
      <dc:creator>Automata</dc:creator>
      <pubDate>Mon, 17 Jun 2024 00:33:48 +0000</pubDate>
      <link>https://forem.com/automata/install-php-83-and-to-config-apache-in-ubuntu-2204-602</link>
      <guid>https://forem.com/automata/install-php-83-and-to-config-apache-in-ubuntu-2204-602</guid>
      <description>&lt;h2&gt;
  
  
  Install PHP:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install php8.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Install PHP module of Apache:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt install libapache2-mod-php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Config PHP Module of Apache
&lt;/h2&gt;

&lt;p&gt;By default, the PHP module is automatically enabled, if for some reason it is not enabled, you should run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a2enmod php8.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To update the PHP module configuration you must modify the files &lt;code&gt;/etc/apache2/mods-enabled/php8.3.conf&lt;/code&gt; and &lt;code&gt;/etc/apache2/mods-enabled/php8.*.load&lt;/code&gt;. Then you must restart the apache server by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl restart apache2.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Confirm Installation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Optional Packages
&lt;/h2&gt;

&lt;h3&gt;
  
  
  PHP-CLI
&lt;/h3&gt;

&lt;p&gt;Run PHP scripts via the CLI&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt install php-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PHP-CGI
&lt;/h3&gt;

&lt;p&gt;Execute PHP scripts without installing the Apache PHP module&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install php-cgi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PHP-MySQL
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt install php-mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PHP-PgSQL
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt install php-pgsql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Install Python 3.11</title>
      <dc:creator>Automata</dc:creator>
      <pubDate>Mon, 06 May 2024 23:32:13 +0000</pubDate>
      <link>https://forem.com/automata/install-python-311-4fib</link>
      <guid>https://forem.com/automata/install-python-311-4fib</guid>
      <description>&lt;h2&gt;
  
  
  Update Ubuntu
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Import Python PPA
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo add-apt-repository ppa:deadsnakes/ppa -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Install Python 3.11
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install python3.11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3.11 --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Install PIP with Python 3.11
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Option 1
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install python3-pip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Option 2
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget https://bootstrap.pypa.io/get-pip.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 get-pip.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 -m pip install --upgrade pip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How to restore a Mysql backup with XAMP</title>
      <dc:creator>Automata</dc:creator>
      <pubDate>Thu, 02 May 2024 16:12:09 +0000</pubDate>
      <link>https://forem.com/automata/how-to-restore-a-mysql-backup-with-xamp-e64</link>
      <guid>https://forem.com/automata/how-to-restore-a-mysql-backup-with-xamp-e64</guid>
      <description>&lt;h2&gt;
  
  
  Update Environment Var:
&lt;/h2&gt;

&lt;p&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%2F1lzbfr9jr16psgjwbt8h.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%2F1lzbfr9jr16psgjwbt8h.png" alt="Update Env vars" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Execution
&lt;/h2&gt;

&lt;p&gt;Execute follow code in Open CMD ✅ (No PowerShell ✖️, No GitBash ✖️):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql -u root -p temabok --force &amp;lt; C:/Users/dbtuser/Documents/temabok_maindb/temabok_maindb.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>xamp</category>
      <category>mysql</category>
      <category>restoremysql</category>
      <category>cmd</category>
    </item>
    <item>
      <title>How does JWT work?</title>
      <dc:creator>Automata</dc:creator>
      <pubDate>Tue, 27 Jun 2023 02:46:47 +0000</pubDate>
      <link>https://forem.com/automata/how-does-jwt-work-1ndm</link>
      <guid>https://forem.com/automata/how-does-jwt-work-1ndm</guid>
      <description>&lt;p&gt;Simply put, JWT is a Token in json format working in the web.&lt;br&gt;
JWT is composed of three parts: Header, payload, signature. &lt;br&gt;
The structure of this looks like this &lt;code&gt;xxxxx.yyyyy.zzzzz&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;# Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Header:&lt;/strong&gt; Contains information about of algorithm and token type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "alg": "HS256",
  "typ": "JWT"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Payload:&lt;/strong&gt;Contains the data that you would like send.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "sub": "1234567890",
  "name": "John Doe",
  "admin": true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Signature:&lt;/strong&gt; For last, the signature do create encoding the Header, Payload and the SECRET. The SECRET must be shared between emisor and receptor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HMACSHA256(
  base64UrlEncode(header) + "." + base64UrlEncode(payload),
  secret
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Libraries: firebase/php-jwt
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require firebase/php-jwt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
require_once 'vendor/autoload.php';  

use \Firebase\JWT\JWT;

// Generate a JWT
$secret= "my_secret";

$payload = array(
    "sub" =&amp;gt; "1234567890",
    "name" =&amp;gt; "John Doe",
    "admin" =&amp;gt; true,
    "iat" =&amp;gt; time(),
    "exp" =&amp;gt; time() + (60 * 60) // JWT valid for 1 hour
);

$jwt = JWT::encode($payload, $secret);

echo "JWT generated: " . $jwt . "\n\n";

// Verify a JWT
try {
    $decoded = JWT::decode($jwt, $clave_secreta, array('HS256'));

    echo "JWT verified:\n";
    print_r($decoded);
} catch (Exception $e) {
    echo "Error verifying el JWT: " . $e-&amp;gt;getMessage();
}
?&amp;gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Aux Tools:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://jwt.io/"&gt;https://jwt.io/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>development</category>
      <category>jwt</category>
      <category>security</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building Docker Container for a Laravel Project</title>
      <dc:creator>Automata</dc:creator>
      <pubDate>Sat, 24 Jun 2023 08:22:57 +0000</pubDate>
      <link>https://forem.com/automata/bring-up-docker-container-with-laravel-project-3007</link>
      <guid>https://forem.com/automata/bring-up-docker-container-with-laravel-project-3007</guid>
      <description>&lt;p&gt;In the first place, we need a web server that can support someone specific php version.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web server: &lt;code&gt;nginx&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Php version: &lt;code&gt;php-7.4&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we need two containers. We will create a &lt;code&gt;docker-composer.yml&lt;/code&gt; usign this structure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Main Directory
└── docker-laravel
    └── docker-compose.yml
    └── README.md
    └── phpfpm
        └── Dockerfile
    └── nginx
        └── default.conf
        └── Dockerfile
    └── laravel-project          # Laravel Project
        └── app.php
        └── ...
        └── composer.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or just we download it in a chosen location using following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/automatape/docker-laravel.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd docker-laravel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For create and start the container (in first plane)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>docker</category>
      <category>laravel</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
