Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /data/sites/web/remonpelnl/www/wp-content/themes/remonpel_nl__child__twentyfourteen/functions.php on line 32
Handy script: lbf – Remons TechNotes

Handy script: lbf

[Edit: This script is defunct since Local rebuilt the application and ditched the virtual machine. This script works only with the old “Local by Flywheel”  and not with the “Local Lightning” app. For the latter, see my lbl script]

Local (by Flywheel) is great, but for a terminal type of person as I am, I find it way more convenient to SSH into a VM and use the WP-CLI to perform WordPress tasks. With a platform like Vagrant, one has the

vagrant ssh
command to shell into the virtual environment.

With Local, you can do this with the push of a button in Local, but as said, I like the terminal better.

lbf ssh
is waaaaay faster than going to the Local app, find the site, click the SSH button.

But wait, there is much more ;)

The lbf command can do the following, from within a directory controlled by Local (for instance ~/Local Sites/mywebsite/app/public)

lbf list List all sites
lbf raw View all info Local has on this site
lbf open Open the site in your default browser
lbf mailhog Open the mailhog software for this site in your default browser
lbf db Open Sequel Pro with the database of this site
lbf ssh [optional: command line] Open the docker shell of this site, or execute the command line inside the docker shell
lbf wp commands Perform WP-CLI operation on site
lbf wpdr Perform wp search-replace <current domain> <local domain>

You can use --site, --project or -p to specify a site, either by Name, ID or Path to operate on
You can use --browser or -b to specify a WebBrowser either by AppName or AppPath to use for ‘open’ and ‘mailhog’
You can use --ssl to use https with operation ‘open’ and ‘wpdr’
You can use browser shortcuts;

-ff
--firefox
Firefox
-fd
--firefox-dev
--firefox-developer-edition
Firefox Developer Edition
-c
--chrome
Chrome
-cd
--chrome-dev
--chromium
Chromium
-o
--opera
Opera
-s
--safari
Safari

Of course, the browser of choice must be installed… Duh…

So, now you can do this: (while inside the app folder)

lbf db
and import a database
lbf wpdr
to make sure the site runs on the local domain
lbf wp plugin install --activate wordpress-seo classic-editor duplicate-post what-the-file wp-smushit
ah, well, you get the idea :)

I would hope to one day add the following commands:

lbf start|stop|restart Start, Stop or Restart the site
lbf vm start|stop|restart Start, Stop or Restart the Local VM
lbf app start|stop|restart Start, Stop or Restart the entire Local ecosystem

The last one, while technically already possible, is not yet useful until the site and vm start/stop/restart options are functional.

Enjoy, but as always; at your own risk :)

Author: Remon Pel

WebDeveloper though not WebDesigner

2 thoughts on “Handy script: lbf”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Confidental Infomation
stop spam mail