承接 soflomo/prototype 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

soflomo/prototype

Composer 安装命令:

composer require soflomo/prototype

包简介

Small module to start fast prototyping of html pages in Zend Framework 2

README 文档

README

Soflomo\Prototype is a small module that helps developers to start creating prototypes of their application. The module aims to create various pages fast and only worry about urls and view templates. Because of its simple goals, frontend developers not experienced with php can create mockups of their designs as well.

Simply said, it allows you to create a mapping between urls and view templates, so websites with a couple of pages are extremely easy to create. Every page has a name, so it is possible to link between pages with the Zend Framework 2 url() view helper.

Installation

Soflomo\Prototype is available through composer. Add "soflomo/prototype" to your composer.json list. During development of Soflomo\Prototype, you can specify the latest available version:

"soflomo/prototype": "dev-master"

Enable the module in your config/application.config.php file. Add an entry Soflomo\Prototype to the list of enabled modules.

Usage

The recommended method is to create a module to hold all the mockup view scripts and the configuration of pages. For example, you call this module Mockups.

Create mockup module

Create a directory Mockup inside the module directory. Create a file Module.php inside this module/Mockup directory with the following contents:

<?php

namespace Mockup;

class Module
{
    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }
}

Then create a folder module/Mockup/config. Create a file module.config.php inside this module/Mockup/config directory with the following contents:

<?php
return array(
    'soflomo_prototype' => array(
    ),

    'view_manager' => array(
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
    ),
);

As a last step, create the directory view inside module/Mockup. This should be enough to get you started for this module.

Enable Mockup module

Locate the file config/application.config.php and put the Mockup module at the end of the list of modules to be enabled. NB. Make sure you also enabled the Soflomo\Prototype module, as described above under "Installation".

Create the pages

The last step is your mockup page configuration. Get back to the module.config.php file in the Mockup module. Inside the soflomo_prototype array, you create (as an example) two pages:

'homepage' => array(
    'route'    => '/',
    'template' => 'mockup/homepage'
),
'hello' => array(
    'route'    => '/hello-world',
    'template' => 'mockup/hello-world'
),

Now you have two pages, one called homepage which is loaded when you load the application / (e.g. http://mysite.localhost/) and the other is called hello and is loaded when you load /hello-world (e.g. http://mysite.localhost/hello-world).

For both pages you need to create a template to be loaded. Inside the module/Mockup/view directory you create a new one mockup and inside it, you create a file homepage.phtml and another hello-world.phtml. Those will be rendered for respectively the homepage and the hello page.

If you need to create a link from one page to another, just use the url() view helper. An example to link to the hello page on the homepage, put this in your homepage.phtml:

<a href="<?php echo $this->url('hello'); ?>">Click me</a>

This will render a link like this:

<a href="/hello-world">Click me</a>

Parametrized routes

Soflomo\Prototype supports route parameters with the segment type route in Zend Framework 2. This means you could have a route like /foo/bar/:id. By default, the module only uses literal routes to match the exact url. This is faster, but less flexible. You can specify to have the segment type by an additional type key:

'homepage' => array(
    'type'     => 'segment',
    'route'    => '/foo/bar/:id',
    'template' => 'mockup/foo-bar'
),

These routes types are extremely useful when dealing with existing applications. If you have an application where you deal with parametrized routes, you want to have a parametrized route for your mockup page as well. This way, you could always navigate back to your real application when a user vists the mocked page.

Why?

You might ask why we built this module and did not use a micro framework like Silex. Or, why we do not start in Zend Framework 2 directly.

To answer the first, micro frameworks are hard to combine with existing Zend Framework 2 applications. We (at Soflomo) need a way to create prototypes also for existing applications. If we prototype a new design for a new module, the existing site with existing designs and existing modules should be kept intact.

However, "normal" Zend Framework 2 configuration is quite some work if you only want to connect routes with view scripts. Frontend developers can easily copy/paste above code for a new module and they are up and running. It simply costs too much time and effort to use the existing nested routes, create controllers, actions, make them loadable via configuration, fetch the view template from the route match options and return a correctly configured view model. For fast protyping, you now just add four lines for a page name, route and view script and it Just Works (tm).

Development

Soflomo\Prototype is intended to create prototypes really fast, but this module is by no means intended for production usage. It is (at this moment) not tested, not stable and there are no guarantees it is bug-free. Use at your own risk!

If you want to join development or found any bug, feel free to fork this project and make your adjustments. Create a pull request to ask for the changes to be merged back in Soflomo\Prototype. If you have any questions about this module, feel free to contact us at jurian@juriansluiman.nl.

soflomo/prototype 适用场景与选型建议

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

它主要适用于以下技术方向: 「zf2」 「prototype」 「mockup」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2013-02-04