smartedutech / littelframeworkapp
小型 MVC 应用程序的框架
Requires
- smartedutech/litelle-framework-generator: ^0.2.0
- smartedutech/littlemvc: ^0.2.0
README
简介
版本:这是一个使用 litelleframwork MVC 层和模块系统构建的应用程序框架。该应用程序旨在为那些想尝试使用 litelleframwork MVC 的人提供一个起点。
使用 Composer 进行安装
创建新的 litelleframwork MVC 项目的最简单方法是使用 Composer。如果您还没有安装,请按照文档进行安装。
创建您的新 littelframework MVC 项目
$ composer create-project -sdev smartedutech/littelframeworkapp path/to/install
安装完成后,您可以使用 PHP 内置的 Web 服务器立即测试它
$ cd path/to/install $ php -S 0.0.0.0:8080 -t public # OR use the composer alias: $ composer run --timeout 0 serve
这将启动端口 8080 上的 cli-server,并将其绑定到所有网络接口。然后您可以通过https://:8080/ 访问网站
- 这将显示 litelleframwork MVC 框架欢迎页面。
注意: 内置 CLI 服务器仅用于开发。
开发模式
您可以使用此项目中包含的简单生成器。生成器是一个名为 smartedutech/litelle-framework-generator 的包。
$ composer require smartedutech/litelle-framework-generator
用于生成 CRUD 的文件是 '/public/generator.php'
配置生成器
要配置 CRUD,您必须实现此文件 'vendor\smartedutech\litelle-framework-generator\src\Configgen\module.php',其中包含包名和数据库表的控制器和操作名。
$_APP_CONF=array(
"APPNAME"=>"e-lab-reservation"
);
"modules"=>array(
"admin"=>array(
"name"=>"admin"
,"Controller"=>array(
)
)
)
''控制器配置 "roles"=>array( "name"=>"roles", "actions"=>array() )
```action configure
"{Controller}"=>array(
"name"=>"{Controller}",
"actions"=>array(
"edit{Table}"=>array(
"Type"=>"simple"//"AJAX"
,'Role'=>"edit"//lister | consulter | gestion | delete | save
,"view"=>array(
"view"=>true
,"layout"=>false
,"pages"=>array(
"edit"=>"edit{Table}"
,"lister"=>"lister{Table}"
//,"id"=>"id{Table}"
)
)
,"activity"=>"edit"
,"form"=>"form{Table}"
,"model"=>array(
"table"=>"{Table}"
)
),
)
运行单元测试
一旦提供测试支持,您可以使用以下方式运行测试
$ ./vendor/bin/phpunit
Web 服务器设置
Apache 设置
要设置 Apache,请创建一个虚拟主机,将其指向项目的 public/ 目录,然后您就可以开始了!它可能看起来像以下这样
<VirtualHost *:80> ServerName litelleframeworkapp.localhost DocumentRoot /path/to/litelleframeworkapp/public <Directory /path/to/litelleframeworkapp/public> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all <IfModule mod_authz_core.c> Require all granted </IfModule> </Directory> </VirtualHost>
Nginx 设置
要设置 nginx,请打开您的 /path/to/nginx/nginx.conf
文件,并在 http
块中添加以下 include 指令(如果尚不存在)
http { # ... include sites-enabled/*.conf; }
它可能看起来像以下这样
server { listen 80; server_name litelleframeworkapp.localhost; root /path/to/litelleframeworkapp/public; location / { index index.php; try_files $uri $uri/ @php; } location @php { # Pass the PHP requests to FastCGI server (php-fpm) on 127.0.0.1:9000 fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /path/to/litelleframeworkapp/public/index.php; include fastcgi_params; } }