Categories
Laravel Samuel

Laravel Deployment Commands

This is just a helpful reminder list of commands to run when deploying code for a Laravel project:

composer update
npm install
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan config:clear

when running php artisan cache:clear if you see the error:

Failed to clear cache. Make sure you have the appropriate permissions.

The data directory most likely doesn’t exist under (storage/framework/cache/data),

This data directory doesn’t exist by default on a fresh/new installation.

Creating the data directory manually at (storage/framework/cache) should fix this issue.

Categories
Laravel Mac Samuel

Fixing NPM Install Error

Ran into this error today when running NPM install on a project:

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1

To Fix this we ran:

xcode-select --print-path
# in my case /Library/Developer/CommandLineTools

# next line deletes the path returned by the command above
sudo rm -rf $(xcode-select --print-path)

# install the tools(again) with
xcode-select --install

Source: https://stackoverflow.com/questions/60573595/npm-install-fails-on-node-gyp-rebuild-with-gyp-no-xcode-or-clt-version-detec 

Once you complete the commands above now run npm install again and live is good 🙂

Categories
Fixing Stuff Laravel Samuel

Setting Up an Old Laravel Project

Steps to setting up an old Laravel project:

First error screen:

Warning: require(/path/public/../vendor/autoload.php): failed to open stream: No such file or directory in /path/public/index.php on line 24

Fatal error: require(): Failed opening required '/path/public/../vendor/autoload.php' (include_path='.:/usr/local/Cellar/php@7.4/7.4.19/share/php@7.4/pear') in /path/public/index.php on line 24

Fix:

run: composer install

Second Error Screen:

Fix:

Download the .env file from the staging site and change it to work with the local DB

Third Error:

ErrorException (E_ERROR)
The Mix manifest does not exist. (View: /path/resources/views/layouts/app.blade.php)
(View: /path/resources/views/layouts/app.blade.php)

Fix:

To fix this we will want to run “npm install followed by npm run dev” however when we run “npm install” we get the error message incorrect or missing password. To fix this we must first do:

download the .npmrc file from staging

rm -rf node_modules
rm package-lock.json
rm yarn.lock
npm cache clear --force
npm install
composer install
npm run dev
now we can run
npm insall 
npm install --save-dev webpack
npm run dev
   type yes to install CLI for webpack

Categories
Development Samuel WordPress

WordPress with Tailwind

This is the first post in a potential series of posts about using WordPress with Tailwind CSS. To start with there is a really great looking repo we can clone down to get us started:

Categories
Fixing Stuff Laravel Samuel

Fixing mix-manifest Error

If you are working in WordPress and see the error message:

Warning: file_get_contents(/file-path/build/mix-manifest.json): failed to open stream: No such file or directory

You can fix this error message with the steps below:

From the root of your project open up the command line and type:

npm install

npm run dev

This will create the build file and the mix-manifest file, and your error should go away.

If you are working in Laravel and see the error message:

The mix manifest does not exist. View:/var/www/html/site-name/resources/views/layouts/app.blad.php

You can fix this with the exact same steps that are listed above 🙂

Categories
Laravel Samuel

Another Laravel 5.5 -> 6.0 Upgrade

First Error:

When trying to save information on the user profile page, we are getting an error if any of the fields are left blank.

Fix:

In App -> Http -> Kernel.php line 22 we will comment out this:

       /* comment this out because its causing errors anytime someone submits a form with an empty value
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
       end comment */

Second Error:

Once on Laravel 6.0 we needed to jump our version of php because the site would not load with our old version of php 7.2 running. We asked valet to use @php7.4 which caused this error message:

Brew was unable to install [php@7.4]

To Fix:

brew update
brew upgrade php
composer global update
valet install
valet use php@7.4
composer global update

*note if the latest version of valet did not come installed with support for php 7.4 (it did, but if it didn’t) then we could have edited this file:

code ~/.composer/vendor/laravel/valet/cli/Valet/Brew.php

class Brew
{
    const SUPPORTED_PHP_VERSIONS = [
        'php',
        'php@7.4',
        'php@7.3',
        'php@7.2',
        'php@7.1',
        'php@7.0',
        'php@5.6',
        'php73',
        'php72',
        'php71',
        'php70',
        'php56'
    ];

*just add php 7.4 to the top of the list, or whatever version of php you need valet to support.

First Error On Staging Site:

When trying to submit a form we get this error message of “undefined index:secret”

Fix:

Double check that the file config -> services.php has the SparkPost varialbes setup correctly, they should be:

 'sparkpost' => [
        'secret' => env('SPARKPOST_SECRET'),

        // optional guzzle specific configuration
        'guzzle' => [
            'verify' => true,
            'decode_content' => true,

    ],

    'options' => [
    // configure endpoint, if not default
    'endpoint' => env('SPARKPOST_ENDPOINT'),

    // optional Sparkpost API options go here
    'return_path' => 'SendingEmail@verifieddomain.com',
    'options' => [
        'open_tracking' => false,
        'click_tracking' => false,
        'transactional' => true,
    ],
   ],
  ],

*You can also see the full list of install tips and config tips for the package here: https://github.com/vemcogroup/laravel-sparkpost-driver