byjg/xmlnuke
Composer 安装命令:
composer create-project byjg/xmlnuke
包简介
PHP Framework based on XML/JSON
README 文档
README
Since 2002 I started the development of the XMLNuke project. I created a framework because I would like to put the best practice I've learning in PHP and I wanted to be more productive. In fact I became more productive developing with XMLNuke than use another framework. Over the years, PHP evolved from your version 3.3 with no code standard to the PSR-*, namespaces, object orientation and the powerful composer. XMLNuke survived to all changes and evolved too. The applications I developed using the XMLNuke framework evolved also and the time did not kill neither the framework project neither the applications are using it.
But XMLNuke had challenges bigger than the PHP and the time. XMLNuke was formed of a single large block piece of software. If you want to use a small feature you had to install and setup all XMLNuke software.
Now is time to move to next step. I learned with XMLNuke and I produced some useful routines and code. Now, XMLNuke project was splitted in several small and manageable projects. This process is going on right now. There are dozen of small projects and this number is continuing to increase. XMLNuke is becoming small and is using these projects.
The most important part of this proccess is the small projects have a better code qualitty (Sensiolab Insigths, Scrutinizer CI and Code Climate) and unit tests (Travis-CI).
The legacy software based on XMLNuke will continue to run, but XMLNuke won't be maintained. You can find the list of the new project in the website OpenSource ByJG
**Long live the king. **
Description
[ The master branch requires PHP53 or higher and is full PSR-0 compliant by using namespaces. The branch 'php50' is the legacy XMLNuke version and is now deprecated. ]
XMLNuke is a Web Development Framework focused on the Data. Programming in XMLNuke you'll never more worry about open and close PHP tags and manage spaghetti code. All of your code is fully based in objects and all code produces only data in XML or JSON, you choose.
This is a page in XMLNuke:
namespace MyProject\Modules; use Xmlnuke\Core\Classes\XmlnukeDocument; use Xmlnuke\Core\Module\BaseModule; class Home extends BaseModule { public function __construct() {} public function CreatePage() { $this->defaultXmlnukeDocument = new XmlnukeDocument("Title", "Abstract"); ... return $this->defaultXmlnukeDocument; } }
You can easily add some requirements to your page without have to care about how handle this. For example, you can define that your page requires authentication, will be cached or requires to be executed in a SSL context. See the example below:
namespace MyProject\Modules; use Xmlnuke\Core\Module\BaseModule; class Home extends BaseModule { /** * requiresAutentication(), getAccessLevel() and getRole() handle the page security and access level */ public functon requiresAutentication() { return true; } public function getAccessLevel() { return \Xmlnuke\Core\Enum\AccessLevel::OnlyRole; } public function getRole() { return new array("DIRECTOR", "MANAGER"); } /** * useCache determines if the XMLNuke will store your page in a cache or not. * By default XMLNuke can store in the: * - \Xmlnuke\Core\Cache\ArrayCacheEngine (Static Array), * - \Xmlnuke\Core\Cache\FileSystemCacheEngine (File System), * - \Xmlnuke\Core\Cache\MemcachedEngine (MemCached), * - \Xmlnuke\Core\Cache\NoCacheEngine (Ignore Cache) * * You can configure your own cache strategy by implementing the interface * \Xmlnuke\Core\Cache\ICacheEngine. */ public function useCache() { if ($this->_action != "") { return false; } else { return true; } } /** * Determines if your page requires SSL or Not */ public function requiresSSL() { return \Xmlnuke\Core\Enum\SSLAccess::ForceSSL; } }
If you work with models using the classic getter and setter or property you can add it to your page and the XMLNuke will output. For example:
namespace MyProject\Classes; class MyClass { protected $_name; public function getName() ...; public function setName($value) ...; protected $_age; public function getAge() ...; public function setAge($value) ...; }
namespace MyProject\Modules; use MyProject\Classes; use Xmlnuke\Core\Classes\XmlnukeDocument; use Xmlnuke\Core\Module\BaseModule; class Home extends BaseModule { public function CreatePage() { $this->defaultXmlnukeDocument = new XmlnukeDocument("Title", "Abstract"); ... $myClass = new MyClass(); $myClass->setName('Joao'); $myClass->setAge(39); ... $this->defaultXmlnukeDocument->addXmlnukeObject($myClass); return $this->defaultXmlnukeDocument; } }
After that you can associate a Snippet XSL to handle this data and produces HTML or whatever you want to produce by the XSL transformation. You can optionally get the raw data in XML or JSON by calling through your web browser:
http://youserver/xmlnuke.php?module=byjg.home&raw=xml&spath=//MyProject_Classes_MyClass
<xmlnuke xpath="//MyProject_Classes_MyClass"> <MyProject_Classes_MyClass> <name>Joao</name> <age>39</age> </MyProject_Classes_MyClass> </xmlnuke>
or
http://yourserver/xmlnuke.php?module=byjg.home&raw=json&xpath=//MyProject_Classes_MyClass;
{
"MyProject_Classes_MyClass": {
"name": "Joao",
"age": "39"
}
}
See the Wiki for more examples;
Installing
The master branch requires PHP 5.3 to run. Prior PHP versions can use the legacy 'php50' branch.
Composer: Project level installation
Composer can download XMLNuke and create a empty XMLNuke project at the same time.
To do this you have to create a empty folder and put the following composer.json file:
{
"require": {
"byjg/xmlnuke": "dev-master"
},
"minimum-stability": "dev",
"scripts": {
"post-install-cmd": [
"Xmlnuke\\Util\\Composer::postInstallCmd"
],
"post-update-cmd" : [
"Xmlnuke\\Util\\Composer::postInstallCmd"
]
}
}
and execute the command:
composer install
This procedure is valid for existing XMLNuke projects also.
Composer: Global installation using global
You can install XMLNuke globally using composer. To do this execute the command:
# use dev-master for stable version # use dev-develop for unstable/develop versions # use the version number for specific version composer global require "byjg/xmlnuke=dev-master"
Make sure that the folder ~/.composer can be accessible by your web server.
It is interesting that the folder ~/.composer/vendor/bin it is the PATH of server:
export PATH=~/.composer/vendor/bin:$PATH
Composer: Global installation using create-project
sudo composer create-project byjg/xmlnuke /opt/xmlnuke dev-master
Command Line (Debian/Ubuntu)
You have to install your web server (Apache2, Lighttd, nginx, ...). XMLNuke requires for PHP:
apt-get install php5-xsl php5-json
Download the XMLNuke package. You can download from:
- the Zip package (https://github.com/byjg/xmlnuke/archive/master.zip) or
- from repository by using the Git or SVN.
Extract the package in any folder, e.g. /opt/xmlnuke. Remember: The XMLNuke folder cannot to be accessible from you Web Browser.
Run at your terminal:
cd /opt/xmlnuke
./copy-dist-files.sh link yes
Choose and create a folder for your project. This folder must be accessible through your web broswer.
mkdir /var/www/my-project
php /opt/xmlnuke/create-php5-project.php /var/www/my-project myproject en-us pt-br
ln -s /opt/xmlnuke/xmlnuke-common /var/www/my-project/common
Now, just test it:
http://yourserver/my-project
Windows
You have to install your web server (Xampp, Apache2, IIS, ...) and configure it to run PHP5 scripts. Make sure that the XSL extension is installed.
Download the XMLNuke package. You can download from:
- the Zip package (https://github.com/byjg/xmlnuke/archive/master.zip) or
- from repository by using the Git or SVN.
Extract the package in any folder, e.g. D:\data\xmlnuke.
Remember: The XMLNuke folder cannot to be accessible from you Web Browser.
Using the Windows Explorer find your XMLNuke folder and double click in the file "copy-dist-files.vbs". Follow the instructions.
Choose and create a folder for your project (e.g. c:\InetPub\wwwroot\my-project). This folder must be accessible through your web broswer. Using the Windows Explorer find your XMLNuke Folder and double click in the file "create-php5-project.vbs" and follow the instructions.
Now, just test it:
http://yourserver/my-project
Development
The master branch is the stable release. All development will be done in the develop branch.
Merge Requests will be accepted in the develop branch.
Pre-Commit Hook.
You can install a pre-commit hook to execute all unit tests before each commit. Install this hook by using the command:
cd <xmlnukedir>
ln -s <xmlnukedir>/utils/git/hooks/pre-commit .git/hooks
byjg/xmlnuke 适用场景与选型建议
byjg/xmlnuke 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 303 次下载、GitHub Stars 达 11, 最近一次更新时间为 2014 年 09 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「json」 「xml」 「api」 「xsl」 「xmlnuke」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 byjg/xmlnuke 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 byjg/xmlnuke 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 byjg/xmlnuke 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
Load DOM document safety
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
统计信息
- 总下载量: 303
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL
- 更新时间: 2014-09-22