Skip to content

Final collaborative project at O'clock school, Tesla 2023 class. Enterprise social network built with React and Laravel. Stack: Laravel 8, PHP 7.4 et MySql 8, Redis.

Notifications You must be signed in to change notification settings

JonGarbayo/o-network-api

Repository files navigation

O'Network (API)

Installation

Dependencies

To run this project on your machine, you will need:

  • Git
  • PHP >= 7.0
  • Composer >= 2
  • MySql or MariaDB
  • Redis (WSL required on Windows)
  • the SQLite driver enabled in your php.ini (for tests only)

Procedure

Clone this repo first:

git clone git@github.com:O-clock-Tesla/projet-02-O-Network-back.git

And in the newly created folder, install the Composer dependencies:

composer install

Now create a new database (o_network for example) with the following command (don't forget to set the desired user instead of root if needed):

mysql -u root -p -e 'CREATE DATABASE o_network'

In the project folder root, make a copy of the .env.example file and rename it .env:

cp .env.example .env

Create also the app key with the following command:

php artisan key:generate

Open the .env file, and set all the values prefixed with DB_ to match your own database configuration. For example, with a database named o_network:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=o_network
DB_USERNAME=root
DB_PASSWORD=root

Configure also all the values prefixed with REDIS_ to match your Redis config. By default, this installation is ready to be used with the predis/predis Composer package as a client. Here are the default ones:

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_CLIENT=predis

To make sending mails work, you need to configure a mail server. You can use any you want, but the .env.example file is prefilled with some values for Mailtrap. So the easy way is to create an account and use the credentials the Mailtrap dashboard provides in the MAIL_USERNAME and MAIL_PASSWORD values:

MAIL_USERNAME=aaaaaaa1111111
MAIL_PASSWORD=bbbbbbb2222222

A symbolic link between the root /public directory and the /storage/app/public one is needed for the server to deliver user profile pictures. Create it with the following command:

php artisan storage:link

The UserSeeder uses the randomuser.me API to generate sample users on development environment, and a SSL certificate is required to query it. Click here to download this one from the Curl website, and put it somewhere on your drive (in your php folder for example). Set the curl.cainfo and openssl.cafile settings in your php.ini to the path of your certificate, like this:

curl.cainfo ="C:\Program Files\php\cert\cacert.pem"
openssl.cafile="C:\Program Files\php\cert\cacert.pem"

Finally, populate the database with the migrations and seed data:

php artisan migrate --seed

Now and every time you need to run the project, don't forget to run your database and Redis server and launch the following command to start the Laravel server:

php artisan serve

About

Final collaborative project at O'clock school, Tesla 2023 class. Enterprise social network built with React and Laravel. Stack: Laravel 8, PHP 7.4 et MySql 8, Redis.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •