Skip to content

Commit

Permalink
Updated docs links
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelgfeller committed Aug 15, 2024
1 parent 9e3cf19 commit 958c806
Show file tree
Hide file tree
Showing 34 changed files with 129 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .cs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* The PHP-CS-Fixer configuration.
*
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Coding-Standards-Fixer
* Documentation: https://samuel-gfeller.ch/docs/Coding-Standards-Fixer
*/
return (new Config())
// Disable the use of cache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/GitHub-Actions#build-testing
# How to deploy: https://github.com/samuelgfeller/slim-example-project/wiki/GitHub-Actions#deploying-to-server
# Documentation: https://samuel-gfeller.ch/docs/GitHub-Actions#build-testing
# How to deploy: https://samuel-gfeller.ch/docs/GitHub-Actions#deploying-to-server
name: 🧪 Build test
on:
push:
Expand Down
47 changes: 23 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@
[![Code Coverage](https://scrutinizer-ci.com/g/samuelgfeller/slim-starter/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/samuelgfeller/slim-starter/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/samuelgfeller/slim-starter/badges/build.png?b=master)](https://scrutinizer-ci.com/g/samuelgfeller/slim-starter/build-status/master)
[![Quality Score](https://img.shields.io/scrutinizer/quality/g/samuelgfeller/slim-starter.svg)](https://scrutinizer-ci.com/g/samuelgfeller/slim-starter/?branch=master)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/samuelgfeller/slim-starter/blob/master/LICENSE)

[Slim 4](https://www.slimframework.com/) full stack starter template to
quickly get started with a scalable PHP web application following 2024 best practices and
[SOLID](https://en.wikipedia.org/wiki/SOLID) principles.
[Slim 4](https://www.slimframework.com/) full stack starter template following 2024 best practices and
[SOLID](https://en.wikipedia.org/wiki/SOLID) principles to quickly get started with a scalable PHP web application.

An extensive [**documentation**](https://github.com/samuelgfeller/slim-example-project/wiki) explains
the [architecture](https://github.com/samuelgfeller/slim-example-project/wiki/Architecture), components,
An extensive [**documentation**](https://samuel-gfeller/docs) explains
the [architecture](https://samuel-gfeller.ch/docs/Architecture), components,
design choices (i.e.
[SRP](https://github.com/samuelgfeller/slim-example-project/wiki/Single-Responsibility-Principle-(SRP)))
[SRP](https://samuel-gfeller.ch/docs/Single-Responsibility-Principle-(SRP)))
and features.
[Libraries](https://github.com/samuelgfeller/slim-example-project/wiki/Libraries-and-Framework)
[Libraries](https://samuel-gfeller.ch/docs/Libraries-and-Framework)
are kept to a minimum and to allow for most flexibility and long-term viability.

</div>
Expand All @@ -33,7 +32,7 @@ Odan's [slim4-skeleton](https://github.com/odan/slim4-skeleton)
but with a lot of additional opinionated
features and examples such as:

* Pages rendered by a [template renderer](https://github.com/samuelgfeller/slim-example-project/wiki/Template-rendering)
* Pages rendered by a [template renderer](https://samuel-gfeller.ch/docs/Template-Rendering)
with layout and versioned assets
* The loading of elements from the database (users) via Ajax
* The creation, modification, and deletion of users with validation
Expand All @@ -48,22 +47,22 @@ a lot more features and examples.
### Technologies

* [Slim 4 micro-framework](https://github.com/slimphp/Slim)
* [Dependency Injection](https://github.com/samuelgfeller/slim-example-project/wiki/Dependency-Injection) - [PHP-DI](https://php-di.org/)
* [Template rendering](https://github.com/samuelgfeller/slim-example-project/wiki/Template-rendering) - [PHP-View](https://github.com/slimphp/PHP-View)
* [Dependency Injection](https://samuel-gfeller.ch/docs/Dependency-Injection) - [PHP-DI](https://php-di.org/)
* [Template rendering](https://samuel-gfeller.ch/docs/Template-Rendering) - [PHP-View](https://github.com/slimphp/PHP-View)
(can be replaced by [Twig](https://twig.symfony.com/))
* [Logging](https://github.com/samuelgfeller/slim-example-project/wiki/Logging) - [Monolog](https://github.com/Seldaek/monolog)
* [Database migrations](https://github.com/samuelgfeller/slim-example-project/wiki/Database-Migrations) - [Phinx](https://phinx.org/)
* [Validation](https://github.com/samuelgfeller/slim-example-project/wiki/Validation) - [cakephp/validation](https://book.cakephp.org/4/en/core-libraries/validation.html)
* [Query Builder](https://github.com/samuelgfeller/slim-example-project/wiki/Repository-and-Query-Builder) - [cakephp/database](https://book.cakephp.org/5/en/orm/query-builder.html)
* [Integration testing](https://github.com/samuelgfeller/slim-example-project/wiki/Writing-Tests) - [PHPUnit](https://github.com/sebastianbergmann/phpunit/)
* [Error handling](https://github.com/samuelgfeller/slim-example-project/wiki/Error-Handling) - [slim-error-renderer](https://github.com/samuelgfeller/slim-error-renderer)
* [GitHub Actions](https://github.com/samuelgfeller/slim-example-project/wiki/GitHub-Actions) and [Scrutinizer](https://github.com/samuelgfeller/slim-example-project/wiki/How-to-set-up-Scrutinizer)
* [Coding standards fixer](https://github.com/samuelgfeller/slim-example-project/wiki/Coding-Standards-Fixer) - [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)
* [Static code analysis](https://github.com/samuelgfeller/slim-example-project/wiki/PHPStan-Static-Code-Analysis) - [PHPStan](https://github.com/phpstan/phpstan)
* [Logging](https://samuel-gfeller.ch/docs/Logging) - [Monolog](https://github.com/Seldaek/monolog)
* [Database migrations](https://samuel-gfeller.ch/docs/Database-Migrations) - [Phinx](https://phinx.org/)
* [Validation](https://samuel-gfeller.ch/docs/Validation) - [cakephp/validation](https://book.cakephp.org/4/en/core-libraries/validation.html)
* [Query Builder](https://samuel-gfeller.ch/docs/Repository-and-Query-Builder) - [cakephp/database](https://book.cakephp.org/5/en/orm/query-builder.html)
* [Integration testing](https://samuel-gfeller.ch/docs/Writing-Tests) - [PHPUnit](https://github.com/sebastianbergmann/phpunit/)
* [Error handling](https://samuel-gfeller.ch/docs/Error-Handling) - [slim-error-renderer](https://github.com/samuelgfeller/slim-error-renderer)
* [GitHub Actions](https://samuel-gfeller.ch/docs/GitHub-Actions) and [Scrutinizer](https://samuel-gfeller.ch/docs/How-to-set-up-Scrutinizer)
* [Coding standards fixer](https://samuel-gfeller.ch/docs/Coding-Standards-Fixer) - [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)
* [Static code analysis](https://samuel-gfeller.ch/docs/PHPStan-Static-Code-Analysis) - [PHPStan](https://github.com/phpstan/phpstan)

## Requirements
* PHP 8.2+
* [Composer](https://github.com/samuelgfeller/slim-example-project/wiki/Composer)
* [Composer](https://samuel-gfeller.ch/docs/Composer)
* MariaDB or MySQL database

## Installation
Expand Down Expand Up @@ -93,7 +92,7 @@ accidentally truncating the development database while testing.
$settings['db']['database'] = 'my_dev_database_name_test';
```

The [Configuration](https://github.com/samuelgfeller/slim-example-project/wiki/Configuration)
The [Configuration](https://samuel-gfeller.ch/docs/Configuration)
documentation details the different configuration files and how they are used and loaded.

#### 3. Run migrations
Expand All @@ -120,7 +119,7 @@ your test database as specified in `config/env/env.test.php`.

If you don't plan on using Scrutinizer, remove the `.scrutinizer` file at the root of the project,
otherwise you can follow this
[guide](https://github.com/samuelgfeller/slim-example-project/wiki/How-to-set-up-Scrutinizer)
[guide](https://samuel-gfeller.ch/docs/How-to-set-up-Scrutinizer)
on how to set it up.

#### Done!
Expand All @@ -132,7 +131,7 @@ directory.

## Support

Please read the [Support❤️](https://github.com/samuelgfeller/slim-example-project/wiki/Support❤️) page
Please read the [Support❤️](https://samuel-gfeller.ch/docs/Support❤️) page
if you value this project and its documentation and want to support it.

## License
Expand Down
2 changes: 1 addition & 1 deletion bin/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Execute a class function instantiated by the container with the command line.
* The first argument is the container key and the second the function name that should be called.
* Example: php bin/console.php SqlSchemaGenerator generateSqlSchema
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Console-Commands
* Documentation: https://samuel-gfeller.ch/docs/Console-Commands
*/

// Boot the application
Expand Down
2 changes: 1 addition & 1 deletion config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Start up the Slim App.
*
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Web-Server-Config-and-Bootstrapping
* Documentation: https://samuel-gfeller.ch/docs/Web-Server-config-and-Slim-Bootstrapping#slim-bootstrapping
*/

use DI\ContainerBuilder;
Expand Down
12 changes: 6 additions & 6 deletions config/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Dependency Injection container configuration.
*
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Dependency-Injection.
* Documentation: https://samuel-gfeller.ch/docs/Dependency-Injection.
*/

use App\Infrastructure\Utility\Settings;
Expand Down Expand Up @@ -58,7 +58,7 @@
return new BasePathMiddleware($container->get(App::class));
},

// Logging: https://github.com/samuelgfeller/slim-example-project/wiki/Logging
// Logging: https://samuel-gfeller.ch/docs/Logging
LoggerInterface::class => function (ContainerInterface $container) {
$loggerSettings = $container->get('settings')['logger'];

Expand All @@ -80,7 +80,7 @@
return $logger->pushHandler($rotatingFileHandler);
},

// Error handling: https://github.com/samuelgfeller/slim-example-project/wiki/Error-Handling
// Error handling: https://samuel-gfeller.ch/docs/Error-Handling
ExceptionHandlingMiddleware::class => function (ContainerInterface $container) {
$settings = $container->get('settings');

Expand Down Expand Up @@ -119,7 +119,7 @@
return $method->invoke($driver);
},
// Used by command line to generate `schema.sql` for integration testing
// Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Test-setup#generating-the-schema-file
// Documentation: https://samuel-gfeller.ch/docs/Test-Setup#generating-the-schema-file
'SqlSchemaGenerator' => function (ContainerInterface $container) {
return new TestTraits\Console\SqlSchemaGenerator(
$container->get(PDO::class),
Expand All @@ -129,12 +129,12 @@
},

// Settings object that classes can inject to get access to the local configuration
// Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Configuration#using-the-settings-class
// Documentation: https://samuel-gfeller.ch/docs/Configuration#using-the-settings-class
Settings::class => function (ContainerInterface $container) {
return new Settings($container->get('settings'));
},

// Template renderer: https://github.com/samuelgfeller/slim-example-project/wiki/Template-rendering
// Template renderer: https://samuel-gfeller.ch/docs/Template-Rendering
PhpRenderer::class => function (ContainerInterface $container) {
$settings = $container->get('settings');
$rendererSettings = $settings['renderer'];
Expand Down
14 changes: 7 additions & 7 deletions config/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* without the risk of overwriting something.
* The only file where the following is permitted: $settings['db'] = ['key' => 'val', 'nextKey' => 'nextVal'];
*
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Configuration.
* Documentation: https://samuel-gfeller.ch/docs/Configuration.
*/
// Set default locale
setlocale(LC_ALL, 'en_US.utf8', 'en_US');
Expand All @@ -25,7 +25,7 @@
'version' => '0.0.0',
// When true, JsImportCacheBuster is enabled and goes through all js files and changes the version number
// from the imports. Should be disabled in env.prod.php.
// https://github.com/samuelgfeller/slim-example-project/wiki/Template-rendering#js-import-cache-busting
// https://samuel-gfeller.ch/docs/Template-Rendering#js-import-cache-busting
'update_js_imports_version' => false,
// Asset path required by the JsImportCacheBuster
'asset_path' => $settings['root_dir'] . '/public/assets',
Expand All @@ -46,7 +46,7 @@

// Secret values are overwritten in env.php
// Query Builder: https://book.cakephp.org/5/en/orm/query-builder.html
// Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Repository-and-Query-Builder
// Documentation: https://samuel-gfeller.ch/docs/Repository-and-Query-Builder
$settings['db'] = [
'host' => '127.0.0.1',
'database' => 'slim_starter',
Expand Down Expand Up @@ -74,14 +74,14 @@
],
];

// API documentation: https://github.com/samuelgfeller/slim-example-project/wiki/API-Endpoint
// API documentation: https://samuel-gfeller.ch/docs/API-Endpoint
$settings['api'] = [
// Url that is allowed to make api calls to this app
'allowed_origin' => null,
];

// Phinx database migration settings
// Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Database-Migrations
// Documentation: https://samuel-gfeller.ch/docs/Database-Migrations
// Libraries: https://github.com/odan/phinx-migrations-generator, https://book.cakephp.org/phinx/0/en/index.html
$settings['phinx'] = [
'paths' => [
Expand All @@ -102,13 +102,13 @@
];

// Template renderer settings
// Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Template-rendering
// Documentation: https://samuel-gfeller.ch/docs/Template-Rendering
$settings['renderer'] = [
// Template path
'path' => $settings['root_dir'] . '/templates',
];

// Logger: https://github.com/samuelgfeller/slim-example-project/wiki/Logging
// Logger: https://samuel-gfeller.ch/docs/Logging
$settings['logger'] = [
// Log file location
'path' => $settings['root_dir'] . '/logs',
Expand Down
6 changes: 3 additions & 3 deletions config/env/env.example.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Secret environment specific configuration values.
* Configuration documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Configuration.
* Configuration documentation: https://samuel-gfeller.ch/docs/Configuration.
*
* Make sure this env.php file is added to .gitignore and ideally place it outside
* the project root directory.
Expand All @@ -12,8 +12,8 @@
*/

// $_ENV['APP_ENV'] should be set to "prod" in the secret env.php file of the prod server.
// APP_ENV should NOT be set to "dev" in the development secret env.php as it
// would override the phpunit.xml APP_ENV setting.
// APP_ENV must NOT be set to "dev" in the development secret env.php as it's already the default value
// and would override the phpunit.xml APP_ENV "test" setting.

// Database
$settings['db']['host'] = 'localhost';
Expand Down
2 changes: 1 addition & 1 deletion config/env/env.phinx.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Migrate command: vendor/bin/phinx migrate -c config/env/env.phinx.php --ansi -vvv
* Generate migration: phinx-migrations generate --overwrite -c config/env/env.phinx.php --ansi
*
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Database-Migrations
* Documentation: https://samuel-gfeller.ch/docs/Database-Migrations
*/

use Cake\Core\Configure;
Expand Down
2 changes: 1 addition & 1 deletion config/env/env.scrutinizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Environment settings for Scrutinizer CI.
* These values are relevant for the .scrutinizer.yml file.
*
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/How-to-set-up-Scrutinizer
* Documentation: https://samuel-gfeller.ch/docs/How-to-set-up-Scrutinizer
*/

// Include testing configuration. Must be "require" and not require_once
Expand Down
2 changes: 1 addition & 1 deletion config/functions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Autoload functions available everywhere across the application.
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Composer#autoload.
* Documentation: https://samuel-gfeller.ch/docs/Composer#autoload.
*
* @param ?string $text
*/
Expand Down
2 changes: 1 addition & 1 deletion config/middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use SlimErrorRenderer\Middleware\NonFatalErrorHandlingMiddleware;

// Slim middlewares are LIFO (last in, first out) so when responding, the order is backwards
// https://github.com/samuelgfeller/slim-example-project/wiki/Middleware#order-of-execution
// https://samuel-gfeller.ch/docs/Slim-Middleware#order-of-execution
return function (App $app) {
$app->addBodyParsingMiddleware();

Expand Down
2 changes: 1 addition & 1 deletion config/settings.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* This file loads the default and environment-specific settings.
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Configuration.
* Documentation: https://samuel-gfeller.ch/docs/Configuration.
*/

// Load default settings
Expand Down
39 changes: 20 additions & 19 deletions public/assets/general/dark-mode/dark-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ if (toggleButton) {
toggleButton.addEventListener('click', switchTheme, false);

// Retrieve the current theme from localStorage
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
const currentTheme = getCurrentTheme();

// Set the theme based on the stored value from localStorage
if (currentTheme) {
// Set the data-theme attribute on the html element
document.documentElement.setAttribute('data-theme', currentTheme);
// Set the data-theme attribute on the html element
document.documentElement.setAttribute('data-theme', currentTheme);

// Check the toggle switch if the current theme is 'dark'
if (currentTheme === 'dark') {
toggleButton.classList.add('dark-theme-enabled');
}
// Check the toggle switch if the current theme is 'dark'
if (currentTheme === 'dark') {
toggleButton.classList.add('dark-theme-enabled');
}
}


/**
* Handle theme switching with localstorage
*
Expand All @@ -41,14 +37,19 @@ function switchTheme(e) {
// Set html data-attribute and local storage entry
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('theme', theme);

// Make ajax call to change value in database
// let userId = document.getElementById('user-id').value;
// submitUpdate({theme: theme}, `users/${userId}`)
// .then(r => {
// }).catch(errorMsg => {
// displayFlashMessage('error', 'Failed to change the theme in the database.')
// });
}


function getCurrentTheme() {
// Check if the user has set a theme in the local storage
if (localStorage.getItem("theme") !== null) {
return localStorage.getItem("theme");
}
// Check if the user has set a global system preference for dark mode
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
// Set the theme to dark mode in localstorage for faster loading in layout
localStorage.setItem("theme", "dark");
return "dark";
}
// Default to light mode
return "light";
}
2 changes: 1 addition & 1 deletion public/assets/user/read/user-read-update-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {createAlertModal} from "../../general/page-component/modal/alert-modal.j

const userId = document.getElementById('user-id').value;

// Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/JavaScript-Frontend#contenteditable-fields
// Documentation: https://samuel-gfeller.ch/docs/JavaScript-Frontend#contenteditable-fields
// Null safe operator as edit icon doesn't exist if not privileged
document.querySelector('#edit-first-name-btn')?.addEventListener('click', makeUserFieldEditable);
document.querySelector('h1[data-name="first_name"]')?.addEventListener('dblclick', makeUserFieldEditable);
Expand Down
2 changes: 1 addition & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Bootstrap the application
*
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Web-Server-Config-and-Bootstrapping
* Documentation: https://samuel-gfeller.ch/docs/Web-Server-config-and-Slim-Bootstrapping#slim-bootstrapping
*/

$app = require __DIR__ . '/../config/bootstrap.php';
Expand Down
2 changes: 1 addition & 1 deletion resources/schema/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ CREATE TABLE `user` (
`created_at` datetime DEFAULT current_timestamp(),
`deleted_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
Loading

0 comments on commit 958c806

Please sign in to comment.