athens/core

适用于学术环境的现代PHP网络框架

0.35.3 2017-12-27 18:38 UTC

README

Build Status Code Climate Test Coverage Latest Stable Version

Athens/Core

Athens 是一个在现代华盛顿大学招生管理系内部构建的现代PHP网络框架。


![Athens in action](doc/assets/images/demo.png) *在 Athens 创建的 Web 应用程序中轻松创建表单和管理提交结果*

Athens 中构建的应用程序

  1. 安全
*Athens* automatically provides strong protection against a number of web attacks, including CSRF, XSS, and database injection.  

*Athens* also provides easy, seamless encryption for sensitive student information. Encrypting a database column requires a simple declaration in your model schema for each data-field you want to protect. Calls to and from the database on that encrypted data are transparent; *Athens* knows which fields are encrypted and handles the encryption/decryption behind the scenes.
  1. 吸引人
*Athens* includes beautiful page templates and user-interface elements. These default templates can be easily overridden with custom themes to implement your own organization's brand.
  1. 易读

    Athens 将页面上的元素声明与元素的外观以及元素的逻辑行为分离。在这个模型下,创建页面并不比列出应存在的展示元素复杂多少。

  2. 可扩展

This separation of concerns also promotes reusability of components: a web-displayed table can be turned into Excel by changing a single line of code; a web-displayed form can be presented as a PDF by changing a single line of code. Adding a column to a table takes only one line, and in most cases *Athens* will be able to populate that column from the database without any further instruction.

开始一个应用程序

有关安装 Athens 并开始新应用程序的帮助,请参阅 应用程序创建教程

安装

此库已在 Packagist 上发布。要使用 Composer 安装,请将 "athens/core": "0.*" 行添加到您的 "require" 依赖项中

{
    "require": {
        ...
        "athens/core": "0.*",
        ...
    }
}

由于 Athens 依赖于多个其他库,因此强烈建议您使用 Composer 安装此库并管理依赖项。

示例

Athens 使用由 PropelORM 生成的类来存储和检索数据库行。首先,我们在 schema.xml 中定义一个学生类

<table name="student">
    <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>

    <column name="uw_student_number" type="varchar" size="7" required="true" phpName="UWStudentNumber"/>
    <column name="first_name" type="varchar" size="127" required="true"/>
    <column name="middle_initial" type="varchar" size="15" required="true"/>
    <column name="last_name" type="varchar" size="127" required="true"/>
    <column name="last_four_ssn" type="varchar" size="4" required="true"/>
</table>

现在我们可以使用 Propel 来生成一个 Student 实例并创建一个将学生在数据库中存储的表单

<?php

require_once dirname(__FILE__) ."/../setup.php";

use Athens\Core\Form\FormBuilder;
use Athens\Core\Page\PageBuilder;
use Athens\Core\Page\Page;

use MyProject\Student;

$form = FormBuilder::begin()
    ->setId("student-form")
    ->addObject(new Student())
    ->build();

$page = PageBuilder::begin()
    ->setId('student-submission-page')
    ->setType(Page::PAGE_TYPE_FULL_HEADER)
    ->setTitle("My Project: Enter a Student")
    ->setHeader("My Project")
    ->setSubHeader("Enter a Student")
    ->setBaseHref("..")
    ->setWritable($form)
    ->build();

$page->render();

附加功能

以下库提供了附加功能

  1. 加密

无缝加密您的敏感数据字段。默认情况下,Athens 项目包括 Encryption 包,以在数据库中静止时加密任何表列。

Athens 项目默认包含 Encryption 包;您只需在 schema.xml 中添加几行即可将加密添加到您的模型中。请参阅 [Encryption 项目文档(/AthensFramework/Encryption/)或应用程序创建教程以获取示例。

  1. SendGrid

通过您的 SendGrid 账户发送电子邮件。通过在设置中添加几行额外的代码,您的 Athens 应用程序将通过 SendGrid 发送所有电子邮件。

默认情况下,SendGrid 包不包括在您的 Athens 项目中;您必须按照项目说明使用此包。

  1. CSRF

Athens 模板项目标准包括使用 CSRF 包对 CSRF 攻击的保护。您可以访问项目文档了解更多信息。

兼容性

  • PHP 5.6, 7.0

待办事项

请参阅 GitHub 问题跟踪器

参与

请随意打开拉取请求或问题。 GitHub 是此项目的规范位置。

以下是代码贡献的一般事件序列

  1. 问题跟踪器 中打开一个问题。
  2. 任何顺序
  • 提交一个带有 失败的 测试的拉取请求,以演示问题/功能。
  • 获得确认/同意。
  1. 修改您的拉取请求以通过(2)中的测试。如果适当,包括文档。

PSR-2 符合性由 Travis 中的 CodeSniffer 强制执行。