<?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: Stev Lasowski</title>
    <description>The latest articles on DEV Community by Stev Lasowski (@stevdev).</description>
    <link>https://dev.to/stevdev</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%2F139158%2F27115119-747f-4c6b-8a98-46bb8b0f3a41.jpg</url>
      <title>DEV Community: Stev Lasowski</title>
      <link>https://dev.to/stevdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stevdev"/>
    <language>en</language>
    <item>
      <title>Auto restarting Laravel Horizon on code changes</title>
      <dc:creator>Stev Lasowski</dc:creator>
      <pubDate>Sun, 14 Jun 2020 17:09:22 +0000</pubDate>
      <link>https://dev.to/stevdev/auto-restarting-laravel-horizon-on-code-changes-3md4</link>
      <guid>https://dev.to/stevdev/auto-restarting-laravel-horizon-on-code-changes-3md4</guid>
      <description>&lt;p&gt;I have been meaning to look into a solution for restarting Laravel Horizon on code changes for a while. Our team uses Docker for our development environment and a container will start with horizon running. However, any code changes would mean we had to restart that container before the changes would load.&lt;/p&gt;

&lt;p&gt;That's when I looked into a solution. It turns out it was pretty simple. There is a handy node tool that will monitor files for changes and restart. I have seen it in use for simple nodejs servers. Enter &lt;a href="https://github.com/remy/nodemon"&gt;nodemon&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can install it in an Ubuntu container with&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt-get update &amp;amp;&amp;amp; apt-get install npm -y &amp;amp;&amp;amp; npm install -g nodemon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now we launch our horizon with the below command &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/usr/local/bin/nodemon --exec /usr/local/bin/php artisan horizon -e php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;the &lt;code&gt;-e php&lt;/code&gt; tells nodemon to monitor all &lt;code&gt;.php&lt;/code&gt; files and restart on a change.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/squareborg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zQj764Ae--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>larvel</category>
      <category>horizon</category>
    </item>
    <item>
      <title>How to deploy OAuth keys on Heroku's ephemeral file system</title>
      <dc:creator>Stev Lasowski</dc:creator>
      <pubDate>Mon, 27 Apr 2020 19:59:16 +0000</pubDate>
      <link>https://dev.to/stevdev/how-to-deploy-oauth-keys-on-heroku-s-ephemeral-file-system-2nkp</link>
      <guid>https://dev.to/stevdev/how-to-deploy-oauth-keys-on-heroku-s-ephemeral-file-system-2nkp</guid>
      <description>&lt;p&gt;Deploying a Laravel + Passport App on Heroku can cause some issues with OAuth Keys.&lt;/p&gt;

&lt;p&gt;You may see this error&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Key path "file:///app/storage/oauth-private.key" does not exist or is not readable&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The problem is your Public and Private OAuth keys are quite rightly ignored in your &lt;code&gt;.gitignore&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;I solved this issue by encrypting the keys and storing them in git, with the help of some custom artisan commands, they are now part of my project but you can grab them. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/squareborg/vendormachine-api/blob/develop/app/Console/Commands/HerokuEncryptKeys.php"&gt;HerokuEncryptKeys.php&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/squareborg/vendormachine-api/blob/develop/app/Console/Commands/HerokuGenerateKey.php"&gt;HerokuGenerateKey.php&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/squareborg/vendormachine-api/blob/develop/app/Console/Commands/HerokuInstallKey.php"&gt;HerokuInstallKey.php&lt;/a&gt;  &lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1
&lt;/h2&gt;

&lt;p&gt;Generate OAuth keys ( if you don't already have some )&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan passport:keys&lt;/code&gt;  &lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2
&lt;/h2&gt;

&lt;p&gt;Generate an encryption key and add the &lt;code&gt;OENCRYPT_KEY&lt;/code&gt; env&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan heroku:generatekey&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;add to your local &lt;code&gt;.env&lt;/code&gt; and also add it to &lt;strong&gt;Heroku's&lt;/strong&gt; env settings&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OENCRYPT_KEY={the output of php artisan heroku:generatekey}&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3
&lt;/h2&gt;

&lt;p&gt;Encrypt your OAuth keys and commit to VCS&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan heroku:encryptkeys&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Commit &lt;code&gt;storage/app/oauth-private.key.encrypted&lt;/code&gt; and &lt;code&gt;storage/app/oauth-pubblic.key.encrypted&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 4
&lt;/h2&gt;

&lt;p&gt;Add  &lt;code&gt;post-install-cmd&lt;/code&gt; to composer.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
        ...
        "post-install-cmd": [ "php artisan heroku:installkeys" ]
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push to git or Heroku and the keys will be unencrypted and installed on build.&lt;/p&gt;

</description>
      <category>heroku</category>
      <category>laravel</category>
      <category>passport</category>
    </item>
  </channel>
</rss>
