专业网页框架
0.9.2
2018-02-14 20:24 UTC
Requires
- php: >=5.4.0
- monolog/monolog: >=1.18,<2.0
- professionalweb/helpers: *
- professionalweb/query-builder: *
Requires (Dev)
This package is auto-updated.
Last update: 2024-08-29 03:47:38 UTC
README
http://pwf.web-development.pw/
项目结构
autoloader/ autoloader
basic/ basic classes
controller/ basic controllers
db/ classes for working with DB
interfaces/ basic interfaces
components/ modules
activerecord/ AR pattern
authorization/ authorization/identity module
compressor/ response minifier
datamapper/ data mapper pattern
datapaginator/ pagination
dbconnection/ database connection module
eventhandler/ event handler
i18n/ internationalization module
monologadapter/ adapter for [Seldaek/monolog](https://github.com/Seldaek/monolog)
observer/ obserber pattern
socialite/ socialite adapter
sphinxql/ adapter for [foolz/sphinxql-query-builder](https://github.com/FoolCode/SphinxQL-Query-Builder)
swiftmailer/ swiftmailer adapter
exception/ exception classes
abstraction/ abstract classes
interfaces/ interfaces
traits/ traits
web/ web/net objects
需求
- PHP 5.4+
依赖
安装
PWF可通过composer获取
composer require professionalweb/pwf "dev-master"
或者您可以将以下内容手动添加到您的composer.json
中的require
部分
"professionalweb/pwf": "dev-master"
之后运行composer update
。
初始化
##index.php
require(__DIR__ . '/../vendor/autoload.php'); (new \project\Application())->run();
##Application.php
namespace project; use pwf\basic\RouteHandler; use Symfony\Component\Yaml\Yaml; class Application extends \pwf\basic\Application { public function __construct() { parent::__construct(Yaml::parse(file_get_contents('../project/config/config.yaml'))); RouteHandler::registerHandler('/', '\project\controllers\MainController::index'); $this->getResponse()->setHeaders([ "Access-Control-Allow-Headers: Content-Type", "Content-Type:text/html; charset=utf-8" ]); } }
控制器
<?php namespace project\controllers; class MainController extends \pwf\basic\WebController { public function index() { $this->title = 'Main page'; return $this->render('project/views/main/index.php', [ 'name' => 'World!' ]); } }
视图
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title><?= $title ?></title> <meta name="keywords" content=""/> <meta name="description" content=""/> </head> <body> <div id="wrapper"> <div id="page"> <div id="content"> Hello, <?= $name ?>! </div> </div> </div> </body> </html>
模型
class PostModel extends \pwf\basic\DBModel { public function __construct(array $attributes = []) { parent::__construct(attributes); $this->table('post'); } }
MIT许可证 (MIT)
版权所有 (c) 2016 Sergey Zinchenko, 专业网页
以下是对任何获得此软件及其相关文档副本(“软件”)的人的免费许可,允许在不限制的情况下处理软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本,并允许向提供软件的人提供这些操作,前提是遵守以下条件
上述版权声明和本许可声明应包含在软件的副本或实质部分中。
本软件按“原样”提供,没有任何形式的保证,明示或暗示,包括但不限于对适销性、特定用途的适用性和非侵权的保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任承担责任,无论是否基于合同、侵权或其他原因,由此软件或其使用或其他方式产生、出现或与之相关。