othyn / challenge

A short code challenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code Challenge

This is the repo for the specified code challenge. Not including keywords as to not resolve GitHub/Google search. This is a standard readme that I have created for all of my projects, in which I update with a new base if I update the style whilst creating a new one, such as this!

Table of contents

Plan & Debrief

To see a complete plan of the project and a post project review, there is a markdown writeup located in the plan directory. This will contain the intentions of the project, even if they were not achieved within a reasonable time frame and a self reflection piece at the end once the project is completed - times up!

Setup

The project runs using a per project installation of Homestead. Instructions on installation and setup, and more specifically the per-project installation are on Laravel's website, although I'll cover the step-by-step process below for getting this up and running for this project. You can find the required database connection information on that documentation.

Prerequisites

These are the underlying requirements of the system in order to develop for the project, assuming you're on macOS. Linux installation steps align almost directly, with most packages either being preconfigured or easily available through your inbuilt distro's package manager such as apt or yum. Windows installion is a little different, but most steps are replaced with package auto-installers instead.

  1. Install brew, which is a delicious pacakge manager for macOS! Helps you for a myriad of things, not just this, an amazing tool.

  2. Install a hypervisor, I recommended VirtualBox in this instance and will walk through assuming so. The virtualbox app should then be present in your applications directory.

  3. Install Vagrant, check this is installed by running $ vagrant -v in your console window. This should print out the version number for the installed version of Vagrant, something like $ vagrant x.y.z.

  4. Install PHP7. At the time of writing this, PHP requires manually updating on macOS to the latest version of PHP7. The easiest way to do this is via php-osx.liip, not forgetting to also update your PATH! Check this is installed by running $ php -v in your console, this should print out the version number for the installed version of PHP in the same manner Vagrant did.

  5. Install Composer via brew $ brew update then $ brew tap homebrew/homebrew-php finally $ brew install composer. Check this is installed by running $ composer -V in your console, this should print out the version number for the installed version of Composer in the same manner Vagrant and PHP did.

  6. Install Node & NPM, via brew $ brew update then $ brew install node. Check this is installed by running $ node -v & $ npm -v in your console, this should print out the version number for the installed version of Node & NPM in the same manner Vagrant, PHP and Composer did

  7. Install Yarn, via brew $ brew install yarn --without-node. Check this is installed by running $ yarn -v in your console, this should print out the version number for the installed version of Yarn in the same manner Vagrant, PHP, Composer, Node & NPM did.

Consistency is nice.

Installation

These are the requirements for the project specifically, installing project dependencies via composer & yarn, plus setting up Homestead for use with Vagrant.

You can also use the installation script in the root of the project directory:

$ cd /project/clone/dir && ./install.sh

You may need to make the script executable, the flag has been written to git, but incase it hasn't flagged the file, run the following and then try the above command again:

$ chmod +x /project/clone/dir/install.sh

... or the steps below can be followed:

  1. Clone the project somewhere on your machine to work out of. I recommend somewhere easily accessible, ~/git/challenge. $ cd into the project, wherever you cloned it, as all of the below will need to be executed from within it.

  2. Run $ composer install to install the required project dependencies, this may take a while...

  3. Run $ yarn install to install the required project dependencies, this again may take a while...

  4. Run $ php vendor/bin/homestead make which will get a Homestead config file generated, filled with the contents of the example file, but it will work out the absolute project directory for you, which is nice!

  5. Check that you have a key pair setup for Homestead, this defaults to id_rsa. To check this, $ ls -la ~/.ssh and see if the keys are present. If not $ ssh-keygen -t rsa will generate you the key pair - or you can modify the homestead.yaml config to use a different key pair.

  6. You'll need to modify your hosts file to map challenge.test to the IP address specified in your homestead.yaml config, I recommend GasMask as an easy to use tool on macOS to quick edit and apply host file changes.

  7. Now to create yourself a local env file, $ cp .env.example .env. You'll then need to run $ php artisan key:generate otherwise you'll just be staring at Laravel's default error screen!

Done!

Development

Run $ vagrant up. The first time the box is used, it will download the source vagrant box which may take some time. After it's finished its boot and provision, you can navigate to challenge.test in your browser.

Laravel Mix powers client side asset development, run $ yarn dev to compile assets one off without minification or production rules, or run a watcher with $ yarn watch - although this doesn't always pickup sass changes.

To see emails being sent, the application uses the log driver, which logs them to the bottom of Laravel's log output. I could have used PHP's inbuilt mail function, or a testing API service (theres loads around), but this way it dumps the email - which would send if you replace the driver in your .env file - to the log at /storage/logs/*.log.

About

A short code challenge

License:GNU General Public License v3.0


Languages

Language:PHP 90.5%Language:HTML 7.6%Language:Shell 1.3%Language:Vue 0.6%