andrebian-solucoes-web / zf-base
该软件包已被废弃,不再维护。作者建议使用andrebian/laminas-base软件包代替。
一个Zend Framework 3 Bootstrap项目
dev-master
2020-04-14 10:47 UTC
Requires
- php: ^7.0 || ^7.1 || ^7.2
- ext-json: *
- andrebian/brazilian-helpers: *
- andrebian/sendgrid-transport-module: *
- doctrine/doctrine-orm-module: *
- kevinlebrun/slug.php: @stable
- phpoffice/phpexcel: ^1.8
- zendframework/zend-component-installer: ^1.0 || ^0.3 || ^1.0.0-dev@dev
- zendframework/zend-db: ^2.8.1
- zendframework/zend-json: ^3.0
- zendframework/zend-log: ^2.9
- zendframework/zend-mail: ^2.7
- zendframework/zend-mvc: ^3.0.1
- zendframework/zend-mvc-console: ^1.1.10
- zendframework/zend-mvc-form: ^1.0
- zendframework/zend-mvc-i18n: ^1.0
- zendframework/zend-mvc-plugins: ^1.0.1
- zendframework/zend-psr7bridge: ^0.2.2
- zendframework/zend-servicemanager-di: ^1.0
- zendframework/zend-session: ^2.7.1
Requires (Dev)
- dkorsak/doctrine-data-fixture-module: *
- doctrine/migrations: ^1.5
- mockery/mockery: ^1.0
- phpstan/phpstan: ^0.11.15
- squizlabs/php_codesniffer: 3.*
- zendframework/zend-developer-tools: ^1.1.0
- zendframework/zend-test: ^3.0.1
- zfcampus/zf-development-mode: ^3.0
This package is auto-updated.
Last update: 2020-04-14 11:30:16 UTC
README
已过时:建议您使用https://github.com/andrebian/laminas-base代替。
适用于多用途应用的Zend Framework Bootstrap应用程序。
1 - 安装
1.1 - 使用Composer创建项目
composer create-project -sdev andrebian-solucoes-web/zf-base path/to/installation
1.2 - 克隆仓库
克隆此仓库,在开始编码之前删除.git
文件夹。
1.3 - 下载ZIP文件
下载ZIP文件,在开始编码之前删除.git
文件夹。
注意
使用Composer安装依赖项时,将出现一些问题。
- Installing doctrine/doctrine-module (dev-master 57c0ee9): Cloning 57c0ee9586 from cache Please select which config file you wish to inject 'DoctrineModule' into: [0] Do not inject [1] config/development.config.php.dist Make your selection (default is 0):0 Remember this option for other packages of the same type? (y/N)y
只需选择“0”选项。所有项目依赖项已在config/modules.config.php
中设置。然后选择“y”选项以记住此决定,适用于相同类型的包。
2 - 初始化应用程序
2.1 - 创建数据库
CREATE SCHEMA `your_db_name` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
2.2 - 设置数据库配置
将文件config/autoload/doctrine_orm.local.php.dist
复制到config/autoload/doctrine_orm.local.php
。之后编辑结果文件并设置您的数据库配置。
# File config/autoload/doctrine_orm.local.php return [ 'doctrine' => [ 'connection' => [ 'orm_default' => [ 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', 'params' => [ 'host' => 'host', 'port' => '3306', 'user' => 'user', 'password' => 'password', 'dbname' => 'dbname', 'driverOptions' => [ PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" ] ] ] ] ], 'dbal' => [ 'types' => [ 'datetime' => \BaseApplication\Database\Mysql\CustomDateTimeType::class ] ] ];
2.3 - 更新架构
在composer.json
中配置了一个更新架构的命令。此命令的名称为update-db。
composer update-db
结果如下所示
composer update-db > doctrine-module migrations:diff Loading configuration from the integration code of your framework (setter). Generated new migration class to "data/DoctrineORMModule/Migrations/Version20180722171236.php" from schema differences. > doctrine-module migrations:migrate --no-interaction Loading configuration from the integration code of your framework (setter). Doctrine Database Migrations Migrating up to 20180722171236 from 0 ++ migrating 20180722171236 -> CREATE TABLE user_users (id INT AUTO_INCREMENT NOT NULL, role_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, username VARCHAR(255) NOT NULL, password VARCHAR(60) NOT NULL, avatar LONGTEXT DEFAULT NULL, last_login DATETIME DEFAULT NULL, created DATETIME DEFAULT NULL, modified DATETIME DEFAULT NULL, active TINYINT(1) DEFAULT '1' NOT NULL, INDEX IDX_F6415EB1D60322AC (role_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB -> CREATE TABLE user_roles (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, created DATETIME DEFAULT NULL, modified DATETIME DEFAULT NULL, active TINYINT(1) DEFAULT '1' NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB -> CREATE TABLE user_password_recoveries (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, created DATETIME DEFAULT NULL, modified DATETIME DEFAULT NULL, active TINYINT(1) DEFAULT '1' NOT NULL, INDEX IDX_7F8992A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB -> ALTER TABLE user_users ADD CONSTRAINT FK_F6415EB1D60322AC FOREIGN KEY (role_id) REFERENCES user_roles (id) -> ALTER TABLE user_password_recoveries ADD CONSTRAINT FK_7F8992A76ED395 FOREIGN KEY (user_id) REFERENCES user_users (id) ++ migrated (0.61s) ------------------------ ++ finished in 0.61s ++ 1 migrations executed ++ 5 sql queries > git add data/DoctrineORMModule/Migrations/*.php
2.4 - 初始化固定值
现在只需初始化固定值,您的应用程序即可运行。使用配置的命令fixtures-init。
composer fixtures-init > ./vendor/bin/doctrine-module orm:fixtures:load > purging database > loading [0] User\Fixture\LoadRole > loading [1] User\Fixture\LoadUser
祝您玩得开心!
此项目做什么?
一组常用功能,可加快开发速度。
哪些功能包含在内?
BaseApplication模块
资产:表单元素
- NameField
- SaveButton
- FilterName
避免每次都编写这些元素。
MySQL自定义类型
- CustomDateTime
过滤器
- CurrencyToFloat
- 日期时间
- 浮点值
辅助工具
- 车牌格式化器 - 目前仅适用于巴西汽车
- 电话号码格式化器 - 目前仅适用于巴西电话号码
- 价格格式化器 - 目前仅适用于巴西雷亚尔(BRL)
邮件
电子邮件封装器。轻松发送事务性电子邮件。
验证器
- 姓名和姓氏
视图辅助工具
- 巴西州辅助工具 - 轻松填充巴西州的表单
- JsonDecode - 在视图中解码json数据。对twig模板很有用
- Slugify - 通过给定的字符串生成别名
- Zap Loading - 可定制的WhatsApp Web加载克隆
用户模块
资产
- 会话默认命名空间
身份验证
- 可定制的身份验证适配器
固定数据
- 第一个角色(管理员)
- 第一个注册的用户作为管理员
辅助工具
- UserIdentity - 在会话中获取已认证的用户数据
视图辅助工具
- UserIdentity - 另一个视图辅助工具,用于在会话中获取已认证的用户数据
运行测试
composer test