SPA Skeleton with Mithril.js and Slim Framework
This is a single-page application (SPA) skeleton based on Mithril.js and Slim Framework 4 trying to use good practices.
Demo
https://mithril-slim-skeleton.tebe.ch/
Requirements
- PHP >= 8.0
- Composer >= 2.0
- Node >= 17.0
- NPM >= 8.0
Installation
git clone https://github.com/tbreuss/mithril-slim-skeleton
cd mithril-slim-skeleton
npm install --prefix frontend
composer install --working-dir backend
Features
JS frontend
- Single page application (SPA) using Mithril.js
- Mitosis pattern for simple state management
- Types without TypeScript using JSDoc
- Frontend Tooling with vite.js
- Minimal CSS with Pico.css
- ESLint JavaScript Linter
- Testing
PHP backend
- REST API using Slim Framework 4
- Autoloading (PSR-4)
- Code styles (PSR-12)
- Dependency injection container (PSR-11)
- HTTP message interfaces (PSR-7)
- HTTP Server Request Handlers and Middleware (PSR-15)
- HTTP factories (PSR-17)
- HTTP router and dispatcher (Slim)
- Logging (PSR-3)
- PHPDoc standard (PSR-5, PSR-19)
- PHPStan (Level: max)
- Single action controllers
- Domain Driven Design (DDD) partially
- JWT for (synchronous) authentication
- Unit Tests
- Integration Tests
Database
- SQLite database
- Migration scripts
- Seed scripts
Development
Start development environment
sh start.sh
Or start backend and frontend manually
Backend
ENVIRONMENT=development php -d variables_order=EGPCS -S localhost:7000 -t backend/public
Frontend
npm run dev --prefix frontend
Scripts
Frontend
Command | Description |
---|---|
eslint:check | eslint . --ext .js |
eslint:fix | eslint . --ext .js --fix |
ts:check | tsc --project jsconfig.json |
ts:check:watch | tsc --watch --project jsconfig.json |
Backend
Command | Description |
---|---|
cs:check | Runs the cs:check script as defined in composer.json. |
cs:fix | Runs the cs:fix script as defined in composer.json. |
lint:check | Runs the lint:check script as defined in composer.json. |
sniffer:check | Runs the sniffer:check script as defined in composer.json. |
sniffer:fix | Runs the sniffer:fix script as defined in composer.json. |
stan:check | Runs the stan:check script as defined in composer.json. |
Links
Toolset used
- https://mithril.js.org/
- https://vitejs.dev/
- https://picocss.com/
- https://www.slimframework.com/
- https://eslint.org/
- https://jsdoc.app/
- https://www.sqlite.org/
Helpful websites, articles, and blog posts
- https://restfulapi.net/http-methods/
- https://dev.to/t7yang/type-safety-in-javascript-with-jsdoc-and-vscode-1a28
- https://depth-first.com/articles/2021/10/20/types-without-typescript/
- https://odan.github.io/slim4-skeleton/
- https://github.com/slimphp/Slim-Skeleton
Contributing
Please create an issue before sending a pull reqest.
License
The MIT License (MIT). Please see License File for more information.