diff --git a/README.md b/README.md index e45dee4df..c61161a8a 100644 --- a/README.md +++ b/README.md @@ -17,22 +17,25 @@ This project is powered by [**Laravel**](https://laravel.com/), a PHP framework # Installation - [Prerequisites](#prerequisites) +- [Pre Setup](#pre-setup) + - [PHP](#php) - [Setup](#setup) - [Web Server](#web-server) - - [Database](#database) - - [PHP](#php) -- [Configuration](#configuration) -- [Users](#users) -- [Elasticsearch](#elasticsearch) -- [Local Storage](#local-storage) -- [Running](#running) + - [Running](#running) +- [Extra Configuration](#extra-configuration) + - [Feature Flags](#feature-flags) + - [Users](#users) + - [Elasticsearch](#elasticsearch) + - [Local Storage](#local-storage) +- [Contributing](#contributing) +- [Resources](#resources) ## Prerequisites * [Laravel Herd](https://herd.laravel.com/) or a webserver such as [Apache](https://httpd.apache.org/download.cgi) or [Nginx](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/) * PHP 8.5 -* MySQL +* MySQL 8+ * [composer](https://getcomposer.org/download/) for vendor dependencies A LAMP stack, such as [XAMPP](https://www.apachefriends.org/download.html), can @@ -41,40 +44,11 @@ also be used to set up Apache, MySQL, and PHP. Alternatively, you may use [Laravel Herd](https://herd.laravel.com), which provides a simple local development environment with PHP and a web server. -## Setup - -```bash -# Clone the repository -git clone git@github.com:AnimeThemes/animethemes-server.git -cd animethemes-server - -# Copy the contents of the `.env.example` file to a new file `.env`. -cp .env.example .env - -# Install vendor dependencies -composer install - -# Set a value for `APP_KEY` -php artisan key:generate - -# Create the database -mysql -h localhost -u root -p -e "CREATE DATABASE IF NOT EXISTS ``animethemes`` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" - -# Import dumps automatically, migrate the database and run seeders -php artisan db:sync -``` - -### Web Server - -Next, we will configure our web server [here](/AnimeThemes/animethemes-server/wiki/Server-Setup) to serve the application. - -If you are using a local development environment such as **Laravel Herd**, the web server and PHP runtime are already configured for you, and you can skip most of the manual web server setup steps. Database support is a paid feature, but you can install MySQL separately. +## Pre Setup ### PHP -#### Required Configuration in `php.ini` - -We should ensure that we have the following extensions enabled for php. +We should ensure that we have the following extensions enabled for php in `php.ini`. `fileinfo` - Needed to detect MIME type of files during seeding. @@ -88,25 +62,44 @@ Set `post_max_size` to `200M`. Set `upload_max_filesize` to `200M`. -### Database +## Setup -Here we will create the database for our development environment. We will assume that we have installed MySQL. +```bash +# Clone the repository +git clone git@github.com:AnimeThemes/animethemes-server.git +cd animethemes-server -**Remark:** Version 8+ is required. +# Create the database +mysql -h localhost -u root -p -e "CREATE DATABASE IF NOT EXISTS ``animethemes`` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" -**Remark:** Ensure that the `pdo_mysql` php extension is enabled in your `php.ini`. +# Install dependencies, migrate the database, run seeders and import dumps +composer setup +``` -If we have installed mysql on our server, we simply create the database using the MySQL command-line client. +### Web Server -## Configuration +#### Laravel Herd + +```sh +# Run the following in the project directory: +herd link animethemes.test +``` + +### Running + +After installation, restart the web server to apply the configuration. + +If all went well, AnimeThemes should be live at `http://animethemes.test` (or whatever set the server name is set to). + +## Extra Configuration + +### Feature Flags Features that require external services are disabled by default. Here we will review the configuration options for enabling additional features. -Development needs will vary depending on the work being done. The list of custom configuration options can be found [here](/AnimeThemes/animethemes-server/wiki/Configuration) for review. +For example, if we want to enable video streams, we need to set the `App\Features\AllowVideoStreams` value on DB to `true`. We recommend setting up a local archive for the `videos_local` disk. -If we want to enable video streams, we need to set the `App\Features\AllowVideoStreams` value on DB to `true`. We recommend setting up a local archive for the `videos_local` disk. - -## Users +### Users ```sh # Open the terminal of tinker @@ -120,11 +113,11 @@ $user = User::factory()->create(['name' => 'User Name', 'email' => 'example@exam $user->assignRole('Admin'); ``` -## Elasticsearch +### Elasticsearch -If we want to enable scout, we need to configure [Elasticsearch](/AnimeThemes/animethemes-server/wiki/Elasticsearch). +If we want to enable scout, we need to configure Elasticsearch. -If we have configured Elasticsearch, migrate and import models into our indices using: +If we have installed Elasticsearch, migrate and import models into our indices using: ```sh # Run the elastic migrations @@ -134,7 +127,7 @@ php artisan elastic:migrate php artisan db:seed --class="Database\Seeders\Scout\ImportModelsSeeder" ``` -## Local Storage +### Local Storage We are not required to set up s3 buckets in order to interact with media. We have the option to configure local filesystems that we can stream audio/video from and download scripts/dumps from. @@ -177,12 +170,6 @@ Create symbolic links to target storage directories. php artisan storage:link ``` -## Running - -After installation, restart the web server to apply the configuration. - -If all went well, AnimeThemes should be live at `http://animethemes.test` (or whatever set the server name is set to). - # Contributing Please review the [**Contributing Guide**](https://github.com/AnimeThemes/animethemes-server/wiki/Contributing) in the wiki for detailed instructions. diff --git a/composer.json b/composer.json index 50b562899..09b5fac5d 100644 --- a/composer.json +++ b/composer.json @@ -108,7 +108,8 @@ "composer install", "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"", "@php artisan key:generate", - "@php artisan db:sync" + "@php artisan db:sync", + "@php artisan optimize" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",