darkalchemy/slim-auth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

darkalchemy/slim-auth

Composer 安装命令:

composer create-project darkalchemy/slim-auth

包简介

A Slim 4 skeleton with authentication

README 文档

README

A Slim 4 Skeleton.

GitHub commits since tagged version Codacy Badge GitHub Issues GitHub license Total Downloads

This is a simple skeleton to quickly ramp up a slim 4 project.

PHP 8 is required
Composer is required
npm/npx is required

Slim 4 as the core framework
nyholm/psr7 for the PSR-7 implementation
php-di/php-di to manage dependency injection
Cartalyst/Sentinel for user authentication and authorization
delight-im/PHP-I18N for handling the users locale
hellogerard/jobby to run all background jobs through cron
Eloquent/ORM for database storage
EmailValidator for validating email addresses
Middlewares/Trailing-slash to remove any trailing slashes in the url
Monolog for logging
PHPMailer for sending email
Phinx for database migrations
Odan/Session for managing the session
Slim/CSRF to protect against csrf
Slim/Flash for flash messaging
Slim/Twig/Flash (updated and included manually) for displaying flash messages in twig
Slim/Twig-View for templates
Slim/Whoops for displaying errors
Twig-Translate for translations
umpirsky/composer-permissions-handler to set folder permissions for log and cache folders
Vlucas/Valitron for validation

To install using composer

composer create-project darkalchemy/slim-auth

cd into project, edit config/settings.php as needed and create the database.

cd slim-auth
nano config/settings.php

After install

composer migrate   # import database

To update for development

composer install           # install non-dev dependencies
npm install                # install dependencies
npm run build-dev          # create initial js/css resources
composer compile           # compile twig templates
composer migrate           # import database

To update for production

composer install --no-dev  # install non-dev dependencies
npm install                # install dependencies
npm run build              # create initial js/css resources
composer compile           # compile twig templates
composer migrate           # import database

Set up cron job, this is necessary to be able to run scripts as www-data when needed

sudo crontab -e

## add this to root crontab
* * * * * cd /path/to/bin folder/ && /usr/bin/php jobby.php 1>> /dev/null 2>&1

Emails do not get sent directly, they are inserted into the database and jobby will take care of sending them.

Compile twig templates for translating

composer compile

Translate all php files to locale - en_US

composer translate en_US

Add additional locales

## check if locale is installed
locale -a

## find correct local
nano /usr/share/i18n/SUPPORTED

## in order to test the locale switcher, I needed to have another locale translated. I translated
## this using Google Translate, so the translation quality may not be very good. Please consider a
## pull request to improve the quality of the translation.
## add locale if not already installed (fr_FR)
sudo locale-gen fr_FR
sudo locale-gen fr_FR.UTF-8
sudo update-locale

## restart webserver (apache2|nginx)
sudo service nginx restart

## edit bootstrap/container.php and add the correct locale to the 'I18n::class' section
nano bootstrap/container.php

Translate all php files to locale - fr_FR

composer translate fr_FR

Then open locale/**/LC_MESSAGES/messages.po in poedit and edit translation.

Then to create the binary forms of the translations, you need to run again for each locale

composer translate en_EN
composer translate fr_FR

Notes

If you want to use redis as your session handler, you should add this to php.ini and uncomment as needed, TCP or Socket

; TCP
; session.save_handler = redis
; session.save_path    = "tcp://127.0.0.1:6379?prefix=SlimAuth:&database=1"

; UNIX Socket
; session.save_handler = redis
; session.save_path = "unix:///dev/shm/redis.sock?prefix=SlimAuth:&database=1"

and add this to your redis.ini file

redis.session.locking_enabled=1

Add these to your apcu.ini

apc.enable_cli=1
apc.slam_defense=1

Available command line commands

composer cleanup          # runs php_cs_fixer
composer clear_cache      # clears all file based caches
composer compile          # compile all twig templates
composer create-migration # create new migration class
composer migrate          # migrate the database
composer rollback         # rollback all database changes
composer set-perms        # set writable perms for cache/log folders for both webserver and cli
composer translate [lang] # translate all strings for listed language
composer translate-all    # translate all strings for all currently available languages
npm build                 # create minified js/css resources
npm build-dev             # create js/css resources

TODO

phpunit for testing.

Credits

Much of what I have done here I learned from watching videos on youtube, Laracasts, Codecourse and from what I have read in many of the online tutorials and Slim Skeletons on github.
Slim4-Skeleton, Slim-Skeleton and Slim4-Starter to list just a few.

I still have a long way to go, but I'm enjoying the trip. This should not be used for any production websites as there are still many things to correct.

darkalchemy/slim-auth 适用场景与选型建议

darkalchemy/slim-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 225 次下载、GitHub Stars 达 29, 最近一次更新时间为 2020 年 02 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Skeleton」 「slim」 「slim-framework」 「slim4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 darkalchemy/slim-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 darkalchemy/slim-auth 我们能提供哪些服务?
定制开发 / 二次开发

基于 darkalchemy/slim-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 225
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 29
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 29
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-15