This repo is home to the Icodestuff website built with Laravel
Homestead is the development environment the website uses to ensure consistency between environments you must use it in order to contribute.
- Download Homebrew
- Download VirtualBox6.X
- Download Vagrant
In your terminal run the following commands:
brew install php
brew install composer
composer install
php vendor/bin/homestead make
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Here is an example of my Homestead.yml file:
ip: 192.168.10.10
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /Users/solomonantoine/icodestuff/website
to: /home/vagrant/code
sites:
- map: local.icodestuff.io
to: /home/vagrant/code/public
php: "7.4"
schedule: true
wildcard: "yes"
databases:
- icodestuff
- icodestuff_testing
features:
- mysql: true
- mariadb: false
- ohmyzsh: true
- webdriver: true
name: icodestuff
hostname: icodestuff
vagrant up
vagrant ssh
Setup your local environment just type setup
into your terminal. This will setup your daemon, redis and
database.
This should happen automatically, but if it doesn't go to: /etc/hosts and paste this:
192.168.10.10 local.icodestuff.io
Be sure the ip address isn't being used more than once.
Please use dependency injection and the IOC container when needing to access services. Stay away from Facades as they are anti-pattern. Read more here why not to use Facades.
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Hash;
class ExampleController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//
}
public function foo()
{
Hash::make(); // bad practice
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Contracts\Hashing\Hasher;
class ExampleController extends Controller
{
private Hasher $hasher;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(Hasher $hasher)
{
$this->hasher = $hasher;
}
public function foo()
{
$this->hasher->make();
}
}
Pass the data to config files instead and then use the config()
helper function to use the data in an application.
$apiKey = env('API_KEY');
// config/api.php
'key' => env('API_KEY');
// Use the data
$apiKey = config('api.key');
To ensure your build doesn't fail, run ./vendor/bin/phpstan analyse
to perform a static analysis check.
Please write tests!! Run php artisan test
before committing your code, to ensure your build doesn't fail.
If you get an issue about composer memory limit just type memory
into your terminal. This will create a swap file
and boost your memory to 4GB.
Sometimes Redis fails to run, to get it going again just run: sudo /etc/init.d/redis-server restart
TODO