Friday, July 17, 2020

Distro-hop Linux Desktops like a pro!

Considering Linux for your daily driver? Not settled on a distro yet? Here's how you can distro-hop like a pro without disrupting your daily workflow.

1. Manage a separate /home partition, or a separate drive altogether. Keep all your files and profiles in one place.

2. Install distros on separate partitions. Limit to 2 distros at a time unless you have enough disk space to go around.

3. Use distro repositories for only essential applications.

4. Install your daily driver applications from 3rd party sources:

a) Flatpak

FlatPaks are installed within the distro like any other apps from distro repositories. Install them for all distros you are hopping between. Many modern repository frontends have started including support for FlatPaks directly within them.

b) AppImage from app developer

AppImages stay in your /home and don't require reinstalling every time you install a new distro.

c) If neither FlatPak nor AppImage is available, then installers directly from the app developer. Install these apps within your /home partition.

5. Get familiar with your boot loader. I use systemd-boot as I find it easy to work with than Grub. You might have another preference.

There it is. You've now minimized application version related incompatibilities (looking at you Firefox and Thunderbird) and your settings and profiles travel with you when you hop.

What are your tips or tricks that have helped you distro hop like a pro?

Sunday, October 28, 2018

Setting up Laravel on Windows 10

Why this guide?

Laravel is quickly becoming a de-facto framework for web application development with PHP. And it is quite an excellent framework. The biggest hurdle in getting started with Laravel development might not be the framework itself, or even the PHP language. I've found the single most frustrating thing about Laravel that developers who are new to Laravel are faced with is the initial software and environment setup.

Even when you go through the tutorials on how to develop applications with Laravel, you will come across commands that seemingly have nothing to do with Laravel programming, but are needed to be run as part of the coding exercises and tasks.

As a result, I've prepared this quick start guide that I hope will help get developers setup with minimal effort and in no time.

Why the guide for Windows and not Linux?

Getting started with Laravel on Linux isn't very difficult at all. All the software you need are easily available through your favorite distribution's repositories and could be installed with a single line of command. Once the necessary software is installed, there is no additional setup required and you can jump right into developing your next multi-million dollar web application.
On Windows, on the other hand, you need to download and install these software packages individually, and there is minimal setup required before you get to a point where you can start focusing on development tasks.

What all do you need?

As of writing this article, Laravel is at version 5.7, and PHP is at version 7.2. For the most part, the instructions described below will not need to install, only download and unzip. The only exception being the database engine, which you'll need to install

PHP

If you didn't already know, Laravel is a PHP framework for web application development and much of the code you write will be in PHP for coding the server-side functionality, while the client-side functionality is coded in a combination of HTML (blade) templates, Javascript, and CSS etc. As such, the first and the most important software you need on your computer for Laravel development has to be PHP which can be downloaded from the following link for Windows - https://windows.php.net/download/
You will download the zip file for the latest stable version.

Download PHP and unzip it under your user's home folder, and rename folder accordingly.

See the screenshot below for reference:



Composer

Composer is a dependency manager for PHP as well as Laravel. It can be downloaded from the following link - https://getcomposer.org/download/
Scroll down towards the "Manual Download" section, and download the latest stable version, 1.7.2 at the time of writing this article.

Save this file "composer.phar" for now. We will get back to this one later.

Node.js

Node.js is a JavaScript runtime technology. It ships with Node Package Manager, or npm, which is needed to trigger compiling web artifacts like JavaScript and CSS to be repackaged in deployable formats.
Node.js can be downloaded from the following link - https://nodejs.org/en/download/
From under LTS, download the Windows Binary (.zip) version for your appropriate processor architecture.

Download Node.js and unzip it under your user's home folder, and rename folder accordingly.

See the screenshot below for reference.



(Optional) MySQL/MariaDB

MySQL and its fork, MariaDB, are some of the most popular database engines available for free download. You may be able to use other database engines so long as you have the appropriate PHP drivers. This is the only software that requires installing.

MySql Community Server installer can be downloaded from https://dev.mysql.com/downloads/
MariaDB Server installer can be downloaded from https://mariadb.com/downloads/

Setting the environment variables

Under Windows 10 Settings, search and open the "Edit environment variables for your account" options.




This should open the "Environment Variables" settings window.



Here, select "Path" and click the "Edit..." button to open the "Edit environment variable" window.



Click "New" and add the path to the PHP folder.
Click "New" again and add the path to the Node.js folder.
Click "OK" to save the settings.

Testing your PHP and Node.js installation
Start a new "Command Prompt" and type the following command to test if PHP installation is setup correctly.

`php -v`

To test Node.js installation, type the following command.

`npm -v`

Both commands should result in version details to be printed on the command prompt like this.


Whatever happened to Composer?

While you could have installed Composer using the Windows installer option, for the purposes of this article, we chose to download the "composer.phar" file instead.

Assuming that the "composer.phar" file is in the user's Downloads, run the following command to test Composer. Make sure you are in the user's folder when typing the command.

`php Downloads\composer.phar --version`

The command should result in version details to be printed on the command prompt like this.




Now your setup is ready!

Creating a test laravel project

Open "Command Prompt" and create a sub folder "Projects" under the user's folder, if not already present, and change the working directory to that "Projects" folder.
Copy the "composer.phar" file from Downloads to the Projects folder and rename it to "composer"
Type the following comand:

`php composer create-project laravel/laravel mywebapp`

Composer should now create your laravel project and start installing all the dependencies.

 
Change the working directory to "mywebapp" folder.
Copy over the "composer" file to this folder.

`copy ..\composer .`

Install "cross-env" package from npm.

`npm install cross-env` 

Install other dependencies from npm.

`npm install`

(Optional) Run the following command to trigger npm to build JavaScript and CSS artifacts.

`npm run dev`


Start Laravel development server

`php artisan serve`


You can now test your application in a browser by going to the address provided.


I hope this article was helpful in your efforts to setup a laravel development environment on Windows.