Skip to content

Installation Guide

samuelgfeller edited this page Mar 30, 2024 · 14 revisions

Requirements

To install and run this project, you need to have PHP 8, Composer, and a MariaDB or MySQL server installed and running on your machine.

XAMPP is a good option to quickly set up a local development environment with all the necessary parts.

1. Create project

Navigate to the directory you want to create the project in and run the following command, replacing [project-name] with the desired name for your project:

composer create-project samuelgfeller/slim-example-project [project-name]

This will create a new directory with the specified name and install all necessary dependencies.

Alternatively, you can use GitHub's Use this template feature to quickly create a repository with the code of this project. Checkout this repository in your preferred IDE before proceeding.

2. Set up the database

After opening the project in your IDE, rename the file config/env/env.example.php to env.php and fill in your database credentials.

Then, create your database and update the config/env/env.dev.php file with the name of your database, like this:

$settings['db']['database'] = 'my_database_name';

After that, create a separate test database and update the config/env/env.test.php file with its name. The name must contain the word "test" as a safety measure to prevent accidentally truncating the development database while testing:

$settings['db']['database'] = 'my_database_name_test';

3. Run migrations

Open the terminal in the project's root directory and run the following command to create the necessary tables for the project:

composer migrate

4. Insert data

You can choose to insert only the minimal amount of data required for the app to function, or also include some dummy example data.

To insert both minimal and dummy data, run:

composer seed

To insert only the minimal data, run:

composer seed:minimal

5. Update GitHub workflows

Deployment
If you are not planning on deploying your app at this time, delete or comment out the contents of the .github/workflows/deploy.yml file.

To deploy your app, update the .github/workflows/deploy.yml file according to your needs and add your server's credentials to GitHub's Actions secrets.

Build testing
To run the project's tests automatically when pushing, update the .github/workflows/develop.yml file.
Replace the matrix value "test-database" slim_example_project_test with the name of your test database as specified in config/env/env.test.php. If you are not using SonarCloud, remove the "SonarCloud Scan" step from the workflow.

Done!

That's it! Your project should now be fully set up and ready to use.
If you are using XAMPP and installed the project in the htdocs folder, you can access it via http://localhost/project-name.
Or you can serve it locally by running php -S localhost:8080 -t public/ in the project's root directory.

Clone this wiki locally