taviroquai/architectphp 问题修复 & 功能扩展

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

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

taviroquai/architectphp

Composer 安装命令:

composer require taviroquai/architectphp

包简介

Architect PHP Framework a pragmatic approach in web development

README 文档

README

Architect PHP Framework uses a pragmatic and modular Web development approach. The idea is to create a small API but with the most common features in web development.

Latest Stable Version Build Status Scrutinizer Quality Score Total Downloads

Online Demo

An online demo can be found in http://marcoafonso.pt/tests/architect/

Install

Look at demo repository at https://github.com/taviroquai/architect-demo/

Main features

  • Small API - You should not need to learn another language. All features can be called in the form app()->featureName(). Use IDE type hinting.
  • Modular and Events architecture
  • Theme slots configuration and Idiom strings are XML files (no programming skills required)

Common features

Most features can be called in 1 line of code, ie. app()->featureName(). If you prefer to use functions style, there are also core functions aliases. Se below.

  • Multiple themes
  • Multiple idioms
  • Routes with PHP5 anonymous functions
  • Events for inter-module actions
  • Fluent Interface DB queries - supports MySQL, PostgreSQL and SQLite
  • Flash messages
  • Application logging
  • Input validation and sanitization
  • Generic views as shopping cart, anti-span input field, file upload, datepicker, pagination, breadcrumbs, carousel, line chart, tree view, file explorer, leaflet map, comment form, automatic table/form from database tables, image gallery, poll and text editor
  • More to come...

This is an on-going work and there is not yet a stable version

Theme Configuration without programming skills

/theme/default/slots.xml

<config>
    <slot name="topbar">
        <module>
            <classname>LoginNavView</classname>
        </module>
    </slot>
</config>

Idiom configuration without programming skills

/idiom/en/default.xml

<items>
	<item key="TITLE">Architect PHP Framework</item>
</items>

API usage examples

All code has type hinting in ie. NetBeans IDE, so it's easy to start.

ALIAS

Architect framework is built using OOP but if you prefer to use functions code styling there are also core function aliases that may speed up development. The first letter gives an idea of what it does. Remember to use IDE type hinting to know how the alias works.

app() - Application. The main gate to access features
conf() - Configuration item. Returns a configuration item
view() - Returns the generic view factory
help() - Returns the helper factory
theme() - Loads a theme or returns current theme
session() - Sets or gets a session item
redirect() - Sends location HTTP header and save session before exit
filter() - calls Input to sanitize an input param
r() - Route. Adds a new route
c() - Content. Adds content to the default theme
u() - URL. Returns an internal URL. Use this to generate internal URLs
m() - Message. Adds a message to be shown to the user
i() - Returns all input parameters or just one from GET/POST
j() - JSON. Sets JSON output
o() - Output. Sets the application Output, ie. a View or plain text
f() - FILES. Returns a FILES entry by index
q() - Query table. Returns a Table instance to start querying
s() - Secure. Returns a secured (encrypted) string
e() - Event. Adds a new event
tr() - TRigger. Triggers the event
v() - View. Creates a new view. You can pass a template file path
l() - Layout. Creates a new layout - a view with layout slots operations

APP

app() // returns the application instance

ROUTER

r('/my/path/(:any)', function ($param) { ... }); // Adds a route callback

THEME

c('Hello World!'); // Adds content to default theme

URL

u('/demo', array('param1' => 'World')); // creates an URL

INPUT (GET / POST / RAW / FILES / CLI ARGS)

i('username'); // returns $_GET['username'] or $_POST['username']
f(0); // returns $_FILES['file'] or $_FILES['file'][0] for multiple

EVENTS

e('my.event.name', function($target) { ... }); // Register an event
tr('my.event.name', $target); // Triggers an event and passes a variable

CORE EVENTS

There are core events that allows to change application workflow without changing the core system. These are:

'arch.module.after.load'
'arch.database.load'
'arch.session.load'
'arch.theme.load'
'arch.action.before.call'
'arch.output.before.send'
'arch.session.save'
'arch.before.end'

IDIOM

$i = help()->createIdiom();  // tries to find a default idiom by session or input
$i->loadTranslation('filename', 'optional module name'); // loads a translation file
$i->translate('key', array('key' => 'World')); // returns translated key in filename
$i->t('TITLE'); // An alias to use in templates

SCREEN MESSAGES

m('An error has occured', 'css class'); // Adds a flash message
app()->flushMessages(); // Returns array. Remember to call flush in template

CAPTCHA

$v = view()->createAntiSpam(); // returns an HTML antispam element
$v->validate(); // validates antispam code (saved in session)

ENCRYPTION

s('secure this string'); // returns an encrypted string (crypt)

REDIRECT

redirect('http://www.google.com'); // redirects to an url

VALIDATION

$v = help()->createValidator();
$rules[] = $v->createRule('email', 'IsEmail', 'Invalid email message);
$result = $v->validate($rules); // more rules at /src/Arch/Rule/
app()->getSession()->loadMessages($v->getMessages());

HTTP

$curl = help()->createCurl('http://google.com'); // gets a Curl helper
$result = $curl->run(); // Gets the URL response
$curl->closeConnection(); // Closes the cURL handler

FILE UPLOAD

$v = view()->createFileUpload(); // Creates an upload field
$v->upload(f($index), '/var/www/architect/theme/data'); // uploads a file

DOWNLOAD

$helper = help()->createDownload('/var/www/architect/theme/data/image.jpg');
$helper->execute(); // forces a file download

DATABASE

q('user')->s()->w('id = ?', array(1))->run(); // select user where id = 1
q('user')->i(array('username' => 'admin'))->run(); // insert into user
q('user')->u(array('username' => 'guest'))->w('id = ?', array(1))->run(); // update
q('user')->d('id = ?', array(1))->run(); // delete from user where id = 1
q('user')->s('group.*')->j('usergroup', 'usergroup.id_group = group.id')->run(); // join

BREADCRUMBS VIEW

view()->createBreadcrumbs(); // returns a breadcrumbs view

DATEPICKER VIEW

view()->createDatepicker(); // returns a date picker view

PAGINATION VIEW

view()->createPagination(); // returns a pagination view

TEXT EDITOR VIEW

view()->createTexteditor(); // returns a text editor view

POLL VIEW

view()->createPoll(); // returns a poll view

LINE CHART VIEW

$data = array(
    array("x" => "2011 W27", "y" => 100),
    array("x" => "2011 W28", "y" => 500)
);
$chart = view()->createLineChart() // returns a new line chart view
    ->set('data', $data)
    ->set('labels', array('Sells'));

TREE VIEW

view()->createTreeView();

FILE EXPLORER VIEW

$explorer = view()->createFileExplorer();
$explorer->setPath($path);

IMAGE GALLERY VIEW

$gallery = view()->createImageGallery()
    ->setPath($path)
    ->setPathToUrl(conf('BASE_URL').$path); // relative url

MAP VIEW

view()->createMap();

CAROUSEL VIEW

view()->createCarousel(); // returns a carousel view

COMMENT FORM VIEW

view()->createCommentForm(); // returns a comment form view

FILE UPLOAD VIEW

view()->createFileUpload(); // returns a file upload view

AUTO TABLE VIEW

$config = array(
    'table'     => 'demo_user',
    'select'    => 'demo_user.*',
    'columns'   => array(
        array('type' => 'value', 'label' => 'Email', 'property'  => 'email'),
        array('type' => 'action',   'icon'  => 'icon-edit', 
            'action' => u('/demo/crud/'), 'property' => 'id')
    )
);
$v = view()->createAutoTable(); // returns an html table view
$v->configure($config, $db);
$v->setPagination($pagination);

AUTO FORM VIEW

$config = array(
    'table'     => 'demo_user',
    'select'    => 'demo_user.*',
    'action'    => u('/demo/crud/save'),
    'items'     => array(
        array('type' => 'hidden',   'property'  => 'id'),
        array('type' => 'label',    'label' => 'Email'),
        array('type' => 'text',     'property'  => 'email'),
        array('type' => 'breakline'),
        array('type' => 'submit',   'label' => 'Save', 
            'class' => 'btn btn-success inline')
    )
);
$v = view()->createAutoForm(); // returns an html form view
$v->configure($config, $db);

ROAD MAP (TODO)

January 2014 - Version 1.0.0-beta
February 2014 - Version 1.0.0

taviroquai/architectphp 适用场景与选型建议

taviroquai/architectphp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 94 次下载、GitHub Stars 达 1, 最近一次更新时间为 2013 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 taviroquai/architectphp 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 94
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-10-31