<?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: Andrew Brooks 👨‍💻</title>
    <description>The latest articles on DEV Community by Andrew Brooks 👨‍💻 (@andrewbrooks).</description>
    <link>https://dev.to/andrewbrooks</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%2F173680%2Fa1ad41b9-3ba1-4a46-b209-a706a9256f4f.png</url>
      <title>DEV Community: Andrew Brooks 👨‍💻</title>
      <link>https://dev.to/andrewbrooks</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andrewbrooks"/>
    <language>en</language>
    <item>
      <title>Using Laravel Valet On Linux/Ubuntu! 🐘 🔑</title>
      <dc:creator>Andrew Brooks 👨‍💻</dc:creator>
      <pubDate>Thu, 21 Nov 2019 19:58:42 +0000</pubDate>
      <link>https://dev.to/andrewbrooks/using-laravel-valet-on-linux-ubuntu-2bcf</link>
      <guid>https://dev.to/andrewbrooks/using-laravel-valet-on-linux-ubuntu-2bcf</guid>
      <description>&lt;p&gt;Valet is an elegant way to create a local webserver for testing your Laravel applications on Mac.&lt;/p&gt;

&lt;p&gt;Fortunately there is a fork allowing us to use Valet on a Linux based OS as well thanks to &lt;a href="https://github.com/cpriego"&gt;@cpriego&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Helpful Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://cpriego.github.io/valet-linux/"&gt;Docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/cpriego/valet-linux"&gt;Repo&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Laravel installation must be complete (see &lt;a href="https://dev.to/andrewbrooks/setting-up-laravel-local-dev-environment-on-ubuntu-51kp"&gt;Setting Up A Laravel Local Dev Environment On Ubuntu&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ubuntu 18.04/19.04&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Installing Dependencies
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install php7.3-curl
sudo apt-get install jq
sudo apt-get install xsel
sudo apt-get install libnss3-tools
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Installing Valet
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer global require cpriego/valet-linux
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test -d ~/.composer &amp;amp;&amp;amp; bash ~/.composer/vendor/bin/valet install || bash ~/.config/composer/vendor/bin/valet install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Restart your terminal&lt;/p&gt;

&lt;h3&gt;
  
  
  Serving your project
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; into project root and run the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;valet park
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The web URL generated will be &lt;code&gt;{project_folder_name}.test&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;laravel new blog

cd blog

valet park
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;will provide a working URL of &lt;code&gt;blog.test&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Things to remember
&lt;/h3&gt;

&lt;p&gt;If you have a local Apache serve running you need to disable it or your Valet URLs will lead to the Apache welcome page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl stop apache2
sudo systemctl disable apache2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To un-park a project &lt;code&gt;cd&lt;/code&gt; into the root and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;valet forget
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;p&gt;I'm Andrew, a full stack software developer from the deep south who makes internet things.&lt;/p&gt;

&lt;p&gt;Hit me up on twitter &lt;a href="http://www.twitter.com/andrew_brooksie"&gt;@andrew_brooksie&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reach out if you have any questions or requests for future write-ups!&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>linux</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What are your favorite Telegram/Slack/Discord dev groups? 🗨️👩‍💻</title>
      <dc:creator>Andrew Brooks 👨‍💻</dc:creator>
      <pubDate>Mon, 26 Aug 2019 03:17:11 +0000</pubDate>
      <link>https://dev.to/andrewbrooks/what-are-your-favorite-telegram-slack-discord-dev-groups-1he2</link>
      <guid>https://dev.to/andrewbrooks/what-are-your-favorite-telegram-slack-discord-dev-groups-1he2</guid>
      <description>

</description>
      <category>discuss</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Setting Up A Laravel Local Dev Environment On Ubuntu 🐘🐧</title>
      <dc:creator>Andrew Brooks 👨‍💻</dc:creator>
      <pubDate>Sun, 18 Aug 2019 22:26:25 +0000</pubDate>
      <link>https://dev.to/andrewbrooks/setting-up-laravel-local-dev-environment-on-ubuntu-51kp</link>
      <guid>https://dev.to/andrewbrooks/setting-up-laravel-local-dev-environment-on-ubuntu-51kp</guid>
      <description>&lt;p&gt;Let's get a simple Laravel dev environment running on Ubuntu desktop 19.04 &amp;amp; 18.04 including a complete MySQL database connection.&lt;/p&gt;

&lt;p&gt;This article assumes some familiarity with the Linux terminal.&lt;/p&gt;

&lt;h1&gt;
  
  
  Install PHP
&lt;/h1&gt;

&lt;p&gt;Add and install the PHP 7.3 PPA&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Verify the PHP version installed&lt;br&gt;
&lt;/p&gt;

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



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PHP 7.3.8-1+ubuntu19.04.1+deb.sury.org+1 (cli) (built: Aug  7 2019 09:52:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.8-1+ubuntu19.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Install MySQL database
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install php7.3-mysql
sudo apt-get install mysql-server
sudo mysql_secure_installation
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now you'll be presented with some prompts. &lt;/p&gt;

&lt;p&gt;For a local dev environment I skip the 'Validate Password Plugin'.&lt;/p&gt;

&lt;p&gt;You will be asked to enter a password for the &lt;code&gt;root&lt;/code&gt; user.&lt;/p&gt;

&lt;p&gt;From there remove the anonymous users, disallow the &lt;code&gt;root&lt;/code&gt; user from remote access, and remove the test database.&lt;/p&gt;

&lt;p&gt;When asked to reload privilege tables select &lt;code&gt;yes&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a non-root user with root privilages
&lt;/h2&gt;

&lt;p&gt;We will use this user when configuring our Laravel application later on.&lt;/p&gt;

&lt;p&gt;Log into MySQL as &lt;code&gt;root&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mysql -u root -p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Run the following SQL to create a new user &lt;code&gt;admin&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;USER&lt;/span&gt; &lt;span class="s1"&gt;'admin'&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="s1"&gt;'localhost'&lt;/span&gt; &lt;span class="n"&gt;IDENTIFIED&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;GRANT&lt;/span&gt; &lt;span class="k"&gt;ALL&lt;/span&gt; &lt;span class="k"&gt;PRIVILEGES&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="s1"&gt;'admin'&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="s1"&gt;'localhost'&lt;/span&gt; &lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="k"&gt;GRANT&lt;/span&gt; &lt;span class="k"&gt;OPTION&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;FLUSH&lt;/span&gt; &lt;span class="k"&gt;PRIVILEGES&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Enter &lt;code&gt;exit&lt;/code&gt; to leave the MySQL CLI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql&amp;gt; exit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Test out the new user by logging in as &lt;code&gt;admin&lt;/code&gt; without using &lt;code&gt;sudo&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql -u admin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.27-0ubuntu0.19.04.1 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql&amp;gt; _
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Exit MySql and we'll move on to installing Composer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql&amp;gt; exit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Install Composer
&lt;/h1&gt;

&lt;p&gt;First, we need to update our package manager.&lt;br&gt;
&lt;/p&gt;

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



&lt;p&gt;Now we are going to install some dependencies needed for the Composer installation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;curl&lt;/code&gt; for downloading Composer&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;php-cli&lt;/code&gt; is needed to run the install&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;php-mbstring&lt;/code&gt; provides functions for a library used&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git&lt;/code&gt; will allow Composer to download project dependencies&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;unzip&lt;/code&gt; for unzipping packages
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install curl php-cli php-mbstring git unzip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;With that out of the way we can download the Composer installer.&lt;/p&gt;

&lt;p&gt;Begin by moving into your home directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and starting the Composer installer download.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -sS https://getcomposer.org/installer -o composer-setup.php
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Before we can run the installer it needs to be verified for corruption.&lt;/p&gt;

&lt;p&gt;Visit &lt;a href="https://composer.github.io/pubkeys.html"&gt;https://composer.github.io/pubkeys.html&lt;/a&gt; and find the '&lt;strong&gt;Installer Signature (SHA-384)&lt;/strong&gt;'&lt;/p&gt;

&lt;p&gt;Use the signature and run the following commands to verify your installer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HASH=your_hash_goes_here
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should see the output of&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Installer verified
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;otherwise you will need to re-download the installer and go through the verification steps again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the installer
&lt;/h2&gt;

&lt;p&gt;Now we are free to install Composer globally on the system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;All settings correct for using Composer
Downloading...

Composer (version 1.9.0) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Lastly we need to update permissions to the composer directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chown -R $USER ~/.composer/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Verify Composer is installed
&lt;/h3&gt;

&lt;p&gt;⚠️ Do not run composer as root using sudo ⚠️&lt;/p&gt;

&lt;p&gt;Simply run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and you should see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.9.0 2019-08-02 20:55:32
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Time for Laravel!
&lt;/h1&gt;

&lt;p&gt;But first, some dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install php7.3-zip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install php7.3-xml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Download the Laravel installer using Composer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer global require laravel/installer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we need to update the Linux &lt;code&gt;$PATH&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' &amp;gt;&amp;gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After updating the &lt;code&gt;$PATH&lt;/code&gt; close your terminal window and open a fresh one.&lt;/p&gt;

&lt;h1&gt;
  
  
  Hello, World
&lt;/h1&gt;

&lt;p&gt;Let's get a boilerplate Laravel app running on our localhost.&lt;/p&gt;

&lt;p&gt;First we will need to create the database that we will be connecting to.&lt;/p&gt;

&lt;p&gt;Log into MySql via the terminal using the &lt;code&gt;admin&lt;/code&gt; user that was created earlier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql -u admin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now run the following SQL to create a database named &lt;code&gt;laravel&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE DATABASE laravel;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;With our database created we can move to the Laravel side of things.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; via the terminal into the folder you want to create your Laravel application in.&lt;/p&gt;

&lt;p&gt;For me that's &lt;code&gt;~/dev/laravel/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run the following command to scaffold the app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;laravel new hello-world
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;hello-world&lt;/code&gt; is just the name of the app so name it whatever you like.&lt;/p&gt;

&lt;p&gt;Once this finishes &lt;code&gt;cd&lt;/code&gt; into the new directory for your app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd hello-world
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;At this point we need to tell the Laravel app how to connect to our database.&lt;/p&gt;

&lt;p&gt;For this we will edit the &lt;code&gt;.env&lt;/code&gt; file in the root of the application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano .env
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The connection settings should look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="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=laravel
DB_USERNAME=admin
DB_PASSWORD=
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can save the changes from nano with &lt;code&gt;ctrl+x&lt;/code&gt;-&amp;gt; &lt;code&gt;'y'&lt;/code&gt; -&amp;gt; &lt;code&gt;[ENTER]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now we need to test this connection.&lt;/p&gt;

&lt;p&gt;For this we will edit &lt;code&gt;/routes/web.php&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It should end up looking like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nx"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&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;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// return view('welcome');&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="na"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;getPdo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nv"&gt;$caught&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="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Exception&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$caught&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;die&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Could not connect to the database.  Please check your configuration. error:"&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt; &lt;span class="p"&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;$caught&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;'Hello, world.'&lt;/span&gt;&lt;span class="p"&gt;;&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;Now start the server by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan serve
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Laravel development server started: &amp;lt;http://127.0.0.1:8000&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now you can check it out in your browser at &lt;a href="http://127.0.0.1:8000"&gt;http://127.0.0.1:8000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should see 'Hello, world.' printed to the screen signalling a successful connection to the database.&lt;/p&gt;

&lt;p&gt;That's it! 🎉&lt;/p&gt;

&lt;p&gt;You now have PHP 7.3, MySql, Composer, and the Laravel installer configured for your local Ubuntu development environment with a running starter Laravel app.&lt;/p&gt;




&lt;p&gt;I'm Andrew, a full stack software developer from the deep south who makes internet things.&lt;/p&gt;

&lt;p&gt;Hit me up on twitter &lt;a href="http://www.twitter.com/andrew_brooksie"&gt;@andrew_brooksie&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reach out if you have any questions or requests for future write-ups!&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
