-
-
Notifications
You must be signed in to change notification settings - Fork 6
Installation Guide
- Requirements
- Create project
- Set up the database
- Run migrations
- Insert data
- Update GitHub workflows
- Done!
To install and run the slim-example-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.
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.
After opening the project in your IDE, rename the file config/env/env.example.php
to config/env/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';
Open the terminal in the project's root directory and run the following command to create the necessary tables for the project:
composer migrate
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
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.
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.
Slim app basics
- Composer
- Web Server config and Bootstrapping
- Dependency Injection
- Configuration
- Routing
- Middleware
- Architecture
- Single Responsibility Principle
- Action
- Domain
- Repository and Query Builder
Features
- Logging
- Validation
- Session and Flash
- Authentication
- Authorization
- Translations
- Mailing
- Console commands
- Database migrations
- Error handling
- Security
- API endpoint
- GitHub Actions
- Scrutinizer
- Coding standards fixer
- PHPStan static code analysis
Testing
Frontend
Other