<?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: Guilherme Lauxen</title>
    <description>The latest articles on DEV Community by Guilherme Lauxen (@guilherme-lauxen).</description>
    <link>https://dev.to/guilherme-lauxen</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%2F1521982%2F3a3561f4-065d-4a64-8276-66f1aa5c8876.jpg</url>
      <title>DEV Community: Guilherme Lauxen</title>
      <link>https://dev.to/guilherme-lauxen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/guilherme-lauxen"/>
    <language>en</language>
    <item>
      <title>Setting Up a Development Environment Using Laravel Sail (Docker)</title>
      <dc:creator>Guilherme Lauxen</dc:creator>
      <pubDate>Fri, 26 Jul 2024 02:18:25 +0000</pubDate>
      <link>https://dev.to/guilherme-lauxen/setting-up-a-development-environment-using-laravel-sail-docker-2fn0</link>
      <guid>https://dev.to/guilherme-lauxen/setting-up-a-development-environment-using-laravel-sail-docker-2fn0</guid>
      <description>&lt;p&gt;Laravel Sail is a lightweight command-line interface for interacting with Laravel’s Docker development environment. It provides a complete development environment that includes PHP, MySQL, Redis and more, without the need for manual installation of these services on your local machine. Laravel Sail is perfect for those who want to quickly start a new Laravel project with a standardized development environment.&lt;/p&gt;

&lt;p&gt;In this post, I’ll show you how to set up the environment with Laravel Sail without having to install the environment locally. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We will only need Docker&lt;/strong&gt;. 🐳&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing the Environment with Laravel Sail
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before you begin, make sure you have Docker installed on your machine. You can download and install Docker from the official website: &lt;a href="https://www.docker.com/get-started" rel="noopener noreferrer"&gt;Docker&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Installing Laravel Sail
&lt;/h3&gt;

&lt;p&gt;Installing Laravel Sail is simple and can be done with a single command. Below are the instructions to install Laravel Sail on MacOS, Windows, and Linux.&lt;br&gt;
Open your terminal and run the following command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://laravel.build/example-app"&lt;/span&gt; | bash


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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;This command will download and configure a new Laravel application called example-app in a directory with the same name. Feel free to replace example-app with your project’s name.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Choosing Your Sail Services
&lt;/h4&gt;

&lt;p&gt;When creating a new Laravel application via Sail, you may use the with query string variable to choose which services should be configured in your new application’s docker-compose.yml file. For available services, see the &lt;a href="https://laravel.com/docs/11.x/installation#choosing-your-sail-services" rel="noopener noreferrer"&gt;Laravel Sail documentation.&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://laravel.build/example-app?with=mysql,redis"&lt;/span&gt; | bash


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

&lt;/div&gt;

&lt;p&gt;If you do not specify which services you would like configured, a default stack will be set up. In Laravel 11, this default stack includes mysql, redis, meilisearch, mailpit, and selenium.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Starting Laravel Sail
&lt;/h3&gt;

&lt;p&gt;Once the installation is complete, navigate to your project’s directory and start the Laravel Sail development environment:&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;example-app
./vendor/bin/sail up


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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;This command will start the Docker containers defined by Laravel Sail, including the web server, database, and other services.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Running Migrations
&lt;/h3&gt;

&lt;p&gt;After starting the environment with sail up, you will need to run the migrations to set up the database:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

./vendor/bin/sail artisan migrate


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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;This command will apply all pending migrations, setting up the database for use with your Laravel application.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating an Alias for the Sail Command
&lt;/h2&gt;

&lt;p&gt;To make using the &lt;code&gt;./vendor/bin/sail&lt;/code&gt; command easier, you can create an alias in your terminal. This will allow you to run &lt;code&gt;sail&lt;/code&gt; commands without typing the full path.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating an Alias on MacOS and Linux
&lt;/h3&gt;

&lt;p&gt;Open your shell configuration file (usually &lt;code&gt;~/.bashrc&lt;/code&gt;, &lt;code&gt;~/.zshrc&lt;/code&gt;, or &lt;code&gt;~/.bash_profile&lt;/code&gt;) and add the following line:&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;alias &lt;/span&gt;&lt;span class="nv"&gt;sail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'[ -f sail ] &amp;amp;&amp;amp; bash sail || bash vendor/bin/sail'&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Then, reload the shell configuration file:&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;source&lt;/span&gt; ~/.bashrc
&lt;span class="c"&gt;# or&lt;/span&gt;
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc
&lt;span class="c"&gt;# or&lt;/span&gt;
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bash_profile


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  Creating an Alias on Windows (PowerShell)
&lt;/h3&gt;

&lt;p&gt;To create an alias in PowerShell, add the following line to your PowerShell profile ($PROFILE):&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;New-Alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;sail&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;vendor/bin/sail&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;Then, reload the PowerShell profile:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="bp"&gt;$PROFILE&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  Using the Alias
&lt;/h3&gt;

&lt;p&gt;Now you can use the sail command directly in the terminal. For example, to start the development environment, simply run:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

sail up


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

&lt;/div&gt;

&lt;p&gt;To run migrations, use:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;p&gt;sail artisan migrate&lt;/p&gt;

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

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Tip: Installing PHP Modules and Extensions&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;If you need to install additional PHP modules or extensions, such as GMP, you can access the Dockerfile used by Laravel Sail and make the necessary modifications.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to the &lt;code&gt;./vendor/laravel/sail/runtimes/&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;Choose the version of PHP you are using (e.g., 8.3).&lt;/li&gt;
&lt;li&gt;Open the corresponding Dockerfile and add the instructions to install the desired extension. For example, to install &lt;code&gt;php8.3-gmp&lt;/code&gt;, you can add:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.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%2F03hr32ab3a20tqhv34fw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F03hr32ab3a20tqhv34fw.png" alt="Install GMP"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After modifying the Dockerfile, rebuild the Docker containers to apply the changes:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;p&gt;sail build &lt;span class="nt"&gt;--no-cache&lt;/span&gt;&lt;/p&gt;

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

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Laravel Sail simplifies the setup of the development environment, providing a standardized and easy-to-use environment. With the steps above, you can install Laravel Sail on MacOS, Windows, and Linux, create an alias to make using Sail commands easier, and install additional modules as needed. &lt;/p&gt;

&lt;p&gt;Try it out and see how Laravel Sail can speed up your development workflow! &lt;/p&gt;

&lt;p&gt;Hope it helps!! 🤓&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>docker</category>
      <category>environment</category>
    </item>
    <item>
      <title>How to Implement Sentiment Analysis with PHP and AWS Comprehend</title>
      <dc:creator>Guilherme Lauxen</dc:creator>
      <pubDate>Wed, 10 Jul 2024 18:58:45 +0000</pubDate>
      <link>https://dev.to/guilherme-lauxen/how-to-implement-sentiment-analysis-with-php-and-aws-comprehend-2ibk</link>
      <guid>https://dev.to/guilherme-lauxen/how-to-implement-sentiment-analysis-with-php-and-aws-comprehend-2ibk</guid>
      <description>&lt;p&gt;Hi everyone, 👋&lt;/p&gt;

&lt;p&gt;Imagine you implement a chatbot that analyzes in real-time how a conversation is going. Is the client happy 😄 or sad 😔 about the situation? Cool, isn’t it? Or imagine analyzing an email from a client and quantifying it in your indicators to see which one needs more attention.&lt;/p&gt;

&lt;p&gt;In this post, I’d like to share how to implement a powerful tool to analyze texts, called AWS Comprehend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important to know:&lt;/strong&gt;&lt;br&gt;
Amazon Comprehend Free Tier allows up to 50,000 character units per month for the first 12 months. After that, you need to check the prices on the AWS platform.&lt;/p&gt;

&lt;p&gt;Hands-on 💪&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create user in AWS.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://aws.amazon.com/pt/console/" rel="noopener noreferrer"&gt;AWS Management Console&lt;/a&gt; and create your login.&lt;/li&gt;
&lt;li&gt;Search for IAM.
&lt;img src="https://media.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%2F6eitv26lhklcv7vkbucr.png" alt="IAM"&gt;
&lt;/li&gt;
&lt;li&gt;Click on Users -&amp;gt; Create User
&lt;img src="https://media.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%2Fyh84ujulve4f40hxt77c.png" alt="Creating user on AWS"&gt;
&lt;/li&gt;
&lt;li&gt;Specify a name (whatever you want) for the user and click on Next
&lt;img src="https://media.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%2Fp72h0k09ze3773giu9y0.png" alt="Specifing a name for the user"&gt;
&lt;/li&gt;
&lt;li&gt;Set permissions for the user.
For our tests, we’re going to use just one policy (ComprehendFullAccess), but for your project, you can define more policies as needed.
&lt;img src="https://media.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%2Fcc5dwqf0jamwb4r362mk.png" alt="Setting permission"&gt;
&lt;/li&gt;
&lt;li&gt;Now it’s time to review and create the user.
&lt;img src="https://media.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%2F5trzt92yqe2yyrhy4h0y.png" alt="Finalize and create user"&gt;
&lt;/li&gt;
&lt;li&gt;After creating the user, it’s time to create an Access Key. Click on the user that has been created, and in Summary, click on Create access key.
&lt;img src="https://media.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%2Fi1f4j3mbjez96euojcxf.png" alt="Summary click create access key"&gt;
&lt;/li&gt;
&lt;li&gt;Select Local code for the use case (for our tutorial it’s fine).
&lt;img src="https://media.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%2Fgdf1eewkxvzv00ljio6x.png" alt="Selecting local code"&gt;
&lt;/li&gt;
&lt;li&gt;Set a description tag. I like to use the name of the case example: local-code-access-key, but you can use any name.
&lt;img src="https://media.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%2Fdm6y7j7zpfm971tiis1e.png" alt="Description tag"&gt;
&lt;/li&gt;
&lt;li&gt;After creating, you can show the access_key and secret_key on the screen or download a CSV with credentials. Save this because we’re going to use it to connect with AWS.
&lt;img src="https://media.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%2Fw6t8586exo0h9zp2sed8.png" alt="Created credentials for access key"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Install the AWS SDK for PHP.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use Composer to install the AWS SDK for PHP library.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;composer require aws/aws-sdk-php&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Implementing code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;This is an example of how you can implement sentiment analysis. Create a file named analyze_sentiment.php and copy this code.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;&amp;lt;?php&lt;br&gt;
require 'vendor/autoload.php';&lt;/p&gt;

&lt;p&gt;// Using the AWS Comprehend library&lt;br&gt;
use Aws\Comprehend\ComprehendClient;&lt;/p&gt;

&lt;p&gt;// Configuring the client&lt;br&gt;
$client = new ComprehendClient([&lt;br&gt;
    'version' =&amp;gt; 'latest',&lt;br&gt;
    'region'  =&amp;gt; 'us-east-1', // Use your preferred region&lt;br&gt;
    'credentials' =&amp;gt; [&lt;br&gt;
        'key'    =&amp;gt; 'PASTE_YOUR_ACCESS_KEY',&lt;br&gt;
        'secret' =&amp;gt; 'PASTE_YOUR_SECRET_ACCESS_KEY',&lt;br&gt;
    ]&lt;br&gt;
]);&lt;/p&gt;

&lt;p&gt;// Text to analyze&lt;br&gt;
$textToAnalyze = 'Thanks for resolving my problem, but it was too late.';&lt;/p&gt;

&lt;p&gt;// Using the method detectSentiment to analyze&lt;br&gt;
$result = $client-&amp;gt;detectSentiment([&lt;br&gt;
    'Text' =&amp;gt; $textToAnalyze,&lt;br&gt;
    'LanguageCode' =&amp;gt; 'en'&lt;br&gt;
]);&lt;/p&gt;

&lt;p&gt;// Result of analysis&lt;br&gt;
echo 'Text: ' . $textToAnalyze;&lt;br&gt;
echo '&amp;lt;br&amp;gt;Sentiment: ' . $result['Sentiment'];&lt;br&gt;
echo '&amp;lt;pre&amp;gt;';&lt;br&gt;
print_r($result['SentimentScore']);&lt;br&gt;
echo '&amp;lt;/pre&amp;gt;';&lt;br&gt;
?&amp;gt;&lt;/p&gt;

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

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  The result looks like this.&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fkaryolacnfs38qhnmbop.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fkaryolacnfs38qhnmbop.png" alt="Result of analysis"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is an example of how you can implement this in your applications. You can use most methods in this library to analyze images, files, and more. Just check the &lt;a href="https://docs.aws.amazon.com/comprehend/latest/dg/what-is.html" rel="noopener noreferrer"&gt;AWS Comprehend Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this is useful for you. 👊&lt;br&gt;
See you soon.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>php</category>
      <category>aws</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
