codelinered/slim-skeleton
Composer 安装命令:
composer create-project codelinered/slim-skeleton
包简介
Slim Skeleton - CodelineRed
关键字:
README 文档
README
This git is for slim3.codelinered.net. Take a look at screenshots.
Table of contents
- Included Third Party Code
- Install Guides
- Path generation with Locale code and Generic locale code
- How to create further localisations
- How to switch between different url modes
- ACL settings
- Troubleshooting
- Links
Included
- Slim 3
- Slim Twig View 2
- Slim CSRF 0.8
- Slim Flash 0.4
- Monolog 1
- Doctrine ORM 2
- Geggleto ACL 1
- Google Authenticator
- Google reCAPTCHA 1
- HTML Compress Twig Extension
Install Skeleton
Required
- PHP 8.0
- MySQL 5.7 (pdo_mysql)
Open console on your OS and navigate to your project folder. Download zip if you don't have git or composer on your OS.
+++++ ZIP VERSION +++++ $ (unix) wget -O slim-prod.zip https://github.com/CodelineRed/slim-skeleton/archive/production.zip $ (unix) unzip slim-prod.zip $ (win10) curl -L -o slim-prod.zip https://github.com/CodelineRed/slim-skeleton/archive/production.zip $ (win10) tar -xf slim-prod.zip $ cd slim-skeleton-production $ (optional) cp config\additional-settings.dist.php config\additional-settings.php $ ---- Open "config\additional-settings.php" and change everything you have to change ---- $ php composer insall --no-dev $ php doctrine dbal:run-sql "CREATE DATABASE slim_skeleton" $ php doctrine orm:schema-tool:update --force $ php doctrine dbal:import sql/all-records.sql
+++++ GIT VERSION +++++ $ git clone https://github.com/CodelineRed/slim-skeleton.git $ cd slim-skeleton $ git checkout production $ (optional on unix) rm -rf .git $ (optional on win10) rmdir .git /s $ (optional) cp config\additional-settings.dist.php config\additional-settings.php $ ---- Open "config\additional-settings.php" and change everything you have to change ---- $ php composer insall --no-dev $ php doctrine dbal:run-sql "CREATE DATABASE slim_skeleton" $ php doctrine orm:schema-tool:update --force $ php doctrine dbal:import sql/all-records.sql
+++++ COMPOSER VERSION +++++ $ php composer create-project codelinered/slim-skeleton slim-skeleton "dev-production" --no-dev $ cd slim-skeleton $ php doctrine dbal:run-sql "CREATE DATABASE slim_skeleton" $ php doctrine orm:schema-tool:update --force $ php doctrine dbal:import sql/all-records.sql
Default Website login: user = user, pass = password If you need PHP, MySQL, Composer and Adminer, see below ⇓.
Install PHP, MySQL, Composer and Adminer (optional)
Required
Open console on your OS and navigate to the unziped/ cloned app folder.
$ (unix) systemctl docker start $ (windows) "c:\path\to\Docker Desktop.exe" $ docker-compose build $ docker-compose up -d $ docker-compose run composer install --no-dev $ (unix) docker inspect slim-db | grep "IPAddress" $ (windows) docker inspect slim-db | findstr "IPAddress" $ ---- Add IPAddress as Doctrine "host" in "config\additional-settings.php" ----
Open localhost:7705 for Website or localhost:7707 for Adminer.
| DB Login | Adminer |
|---|---|
| Server | IP from IPAddress |
| Username | root |
| Password | rootdockerpw |
| Database |
Path generation with Locale code and Generic locale code
- Mode 1 - example.com/de/ =
'process' => \App\Utility\LanguageUtility::LOCALE_URL | \App\Utility\LanguageUtility::DOMAIN_DISABLED, - Mode 2 - example.de =
'process' => \App\Utility\LanguageUtility::LOCALE_URL | \App\Utility\LanguageUtility::DOMAIN_ENABLED, - Mode 3 - example.com (de-DE session) =
'process' => \App\Utility\LanguageUtility::LOCALE_SESSION | \App\Utility\LanguageUtility::DOMAIN_DISABLED,(default)
It depends on your configuration what will be returned.
| Mode 1 | Mode 2 | Mode 3 | |
|---|---|---|---|
| locale code | de-DE | de-DE | xx-XX |
| generic locale code | de-DE | xx-XX | xx-XX |
| Twig | PHP | Twig Example | PHP Example | |
|---|---|---|---|---|
| locale code | {{ lc }} |
LanguageUtility::getLocale() |
{{ path_for('user-register-' ~ lc) }} |
$this->router->pathFor('user-register-' . LanguageUtility::getLocale()) |
| generic locale code | {{ glc }} |
LanguageUtility::getGenericLocale() |
{{ path_for('user-login-' ~ glc) }} |
$this->router->pathFor('user-login-' . LanguageUtility::getGenericLocale()) |
How to create further localisations
- Duplicate one existing file in folder
locale/(e.g. copyde-DE.phptofr-FR.php) - (if you use Mode 1 or 2) Duplicate one existing file in folder
config/routes/(e.g. copyde-DE.phptofr-FR.php) - (if you use Mode 1 or 2) Change route prefix from
/de/to/fr/inconfig/routes/fr-FR.php - You can also define paths like
/fr-be/(locale/fr-BE.php/config/routes/fr-BE.php) for example - If you want to show language in langswitch, add
fr-FRand domain inlocale => active(config/additional-settings.php) - (if you use Mode 1 or 2) Add case for
fr/insrc/localisation.php
How to switch between different url modes
Mode 1
Example: example.com/de/
- EN is default language and DE is alternative language for this steps
- Got to
localeinconfig/additional-settings.php - Set
'process' => \App\Utility\LanguageUtility::LOCALE_URL | \App\Utility\LanguageUtility::DOMAIN_DISABLED, - Set up english routes with or without
/enprefix inconfig/routes/en-US.php - Set up german routes with
/deprefix inconfig/routes/de-DE.php config/routes/xx-XX.phpcan be leave untouched
Mode 2
Example: de.example.com or example.de
- EN is default language and DE is alternative language for this steps
- Got to
localeinconfig/additional-settings.php - Set
'process' => \App\Utility\LanguageUtility::LOCALE_URL | \App\Utility\LanguageUtility::DOMAIN_ENABLED, - Enter your domains in
active - Go to
config/routes/de-DE.php - Remove
/deprefix from everyroute - Go to
config/routes/xx-XX.php - Insert all routes where the config is equal between
config/routes/en-US.phpandconfig/routes/de-DE.php - Remove these equal routes in
config/routes/en-US.phpandconfig/routes/de-DE.php
Mode 3 (default)
Example: example.com
- EN is default language and DE is alternative language for this steps
- Got to
localeinconfig/additional-settings.php - Set
'process' => \App\Utility\LanguageUtility::LOCALE_SESSION | \App\Utility\LanguageUtility::DOMAIN_DISABLED, - Set up all routes in
config/routes/xx-XX.php config/routes/en-US.phpcan be leave untouchedconfig/routes/de-DE.phpcan be leave untouched
ACL settings
With Geggleto ACL, routes are protected by role the current user has. By default every new route is not accessable until you give the route roles.
Routes are defined in the route files (e.g. config/routes/de-DE.php).
Any other resource is defined in config/settings.php.
Inside the Twig templates you can use ACL functions has_role and is_allowed.
Inside controllers you can also use this ACL functions and many more (e.g. isAllowed()).
Troubleshooting
Error 1
In some cases you'll get the error message "Internal Server Error".
If this happened, go to public/.htaccess and enable RewriteBase /.
If project is in sub directory then RewriteBase /project/public/.
Error 2
Message: is not resolvable File: /var/www/vendor/slim/slim/Slim/CallableResolver.php
If this happened, your Doctrine host in config\additional-settings.php is wrong.
Links
codelinered/slim-skeleton 适用场景与选型建议
codelinered/slim-skeleton 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「microframework」 「rest」 「twig」 「recaptcha」 「doctrine」 「router」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codelinered/slim-skeleton 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codelinered/slim-skeleton 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codelinered/slim-skeleton 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
A Twig extension to insert css as inline styles with a tag
Caching and compression for Twig assets (JavaScript and CSS).
Twig extensions for Tracy Debugger
A PSR-7 compatible library for making CRUD API endpoints
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-07