Table of Contents
回复内容:
Home Backend Development PHP Tutorial apache - 大家自己写过哪些PHP框架或者工具?求链接

apache - 大家自己写过哪些PHP框架或者工具?求链接

Jun 06, 2016 pm 08:27 PM
apache php

大家自己写过哪些PHP框架或者工具?求链接

回复内容:

大家自己写过哪些PHP框架或者工具?求链接

我为自己的网站写了个框架,一直在使用 http://github.com/yeaha/Lysine2,每天处理几百万的动态请求

  • RESTful风格的controller
  • 内置DataMapper方式的ORM实现,比ActiveRecord更方便的是后端不仅仅局限于关系式数据库,可以方便的切换为mongodb等存储服务,而model api基本保持不变,且便于分库和分表
  • 支持layout方式的视图
  • mysql/postgresql/sqlite adapter
  • 常用缓存redis/memcached adapter
  • 日志记录
  • 单元测试完整

总计代码4616行,168K,最大的毛病是没文档

<code>Lysine2/src
|-- class_files.php
|-- context.php
|-- core.php
|-- curl.php
|-- datamapper.php
|-- error.php
|-- functions.php
|-- http.php
|-- loader.php
|-- logging.php
|-- mvc.php
|-- service
|   |-- amqp.php
|   |-- db
|   |   |-- mysql.php
|   |   |-- pgsql.php
|   |   `-- sqlite.php
|   |-- db.php
|   |-- manager.php
|   |-- memcached.php
|   `-- redis.php
|-- session.php
`-- traits.php
</code>
Copy after login

phploc统计结果:

<code>Size
  Lines of Code (LOC)                             4616
  Comment Lines of Code (CLOC)                     203 (4.40%)
  Non-Comment Lines of Code (NCLOC)               4413 (95.60%)
  Logical Lines of Code (LLOC)                    1567 (33.95%)
    Classes                                       1402 (89.47%)
      Average Class Length                          23
      Average Method Length                          3
    Functions                                      116 (7.40%)
      Average Function Length                        4
    Not in classes or functions                     49 (3.13%)

Complexity
  Cyclomatic Complexity / LLOC                    0.40
  Cyclomatic Complexity / Number of Methods       2.41

Dependencies
  Global Accesses                                   28
    Global Constants                                 2 (7.14%)
    Global Variables                                 3 (10.71%)
    Super-Global Variables                          23 (82.14%)
  Attribute Accesses                               432
    Non-Static                                     411 (95.14%)
    Static                                          21 (4.86%)
  Method Calls                                     530
    Non-Static                                     465 (87.74%)
    Static                                          65 (12.26%)

Structure
  Namespaces                                        12
  Interfaces                                         2
  Traits                                             3
  Classes                                           60
    Abstract Classes                                 5 (8.33%)
    Concrete Classes                                55 (91.67%)
  Methods                                          395
    Scope
      Non-Static Methods                           370 (93.67%)
      Static Methods                                25 (6.33%)
    Visibility
      Public Method                                314 (79.49%)
      Non-Public Methods                            81 (20.51%)
  Functions                                         26
    Named Functions                                 21 (80.77%)
    Anonymous Functions                              5 (19.23%)
  Constants                                         55
    Global Constants                                 5 (9.09%)
    Class Constants                                 50 (90.91%)
</code>
Copy after login

https://gist.github.com/yeaha/672178
这是一个展示存储服务路由配置的代码片段,用于展示如何分库
配置好以后由mapper使用,对data model完全透明

我写了几个有点另类的框架:

高性能 PHP Socket 服务器框架 workerman
PHP Thrift Rpc远程调用框架 workerman-thrift-rpc
PHP Json Rpc远程调用框架 workerman-json-rpc
PHP聊天室框架 workerman-chat

以上框架都是用PHP Daemon运行的,不用安装 apache、nginx、php-fpm这些软件就能直接跑。

workerman性能很强悍,我每天用它处理过亿的订单请求。

这个帖应该是毛遂自荐帖咯?

之前因为很喜欢fatfree的路由控制(说实话单独的路由控制没找到比fatfree更让我喜欢的),但是因为数据库和模板操作这边我也有其它喜欢的,所以昨天(还是前天?)把fatfree的路由功能给剥离了出来,不是我自己写的,不过也算是独有的(Github没搜到相关的项目),拿出来分享给题主吧,项目地址是:http://github.com/lizheming/F3router

框架这部分的话再推荐两个不是我自己写的东西吧(我是真的很喜欢你造嘛!)。数据库操作推荐一下喵饭大大的 Medoo 以及模板引擎推荐一下 Twig。不过模板这方面如果是做自己用的东西的话我更倾向于用原生的PHP语法去写。

框架因为用的东西不多,能说的也就这么几个了。关于工具的话,之前因为 Jekyll 和 Octopress 的流行,写过一个PHP版的静态博客生成器。很早些的,大换血过好几个版本,一直在更新,项目地址是:http://github.com/lizheming/pmblog

能拿得出手的东西就这么一点了,有问题欢迎反馈。

推荐自己的LitPHP

推荐理由:0.1版本代码行数=270行,表现力丰富,自由整合任何模板/ORM解决方案,有实际生产项目

官网
Github Repo
开发分支
教程
设计理念

一生PHP功力化繁为简凝聚而成。除了组织代码和一些路由之外,没有任何功能,删无可删。也就是说任何功能都由你自己适配上去从而保持100%控制权,任何自己喜欢的模式都可以轻松套进去。

做框架的框架,让每个应用都躺在量身打造的框架中。

代码:

https://github.com/liaohuqiu/cube-php

文档:

http://cube-php.liaohuqiu.net/

这三年来一直在用的东西,这个框架支撑起来的业务曾经红极一时。名字随便起的,代码也还没完全整理好。

好些时间没写php了,最近忙里偷闲,重新拾起,开源出去,了一个念想,换一个纪念。


  1. 实现标准的autoload规则,允许各种框架接入
  2. 分库分表
  3. 极其简单的路由
  4. 对话框,ajax请求,客户端API请求,5分钟可以上手。
  5. 附送一个管理后台
  6. 附送一个JS框架

https://github.com/lloydzhou/router

  1. 一个只有100行的路由控制器,算不上框架了。

  2. 不使用正则表达式做路由映射,而是根据pathinfo创建树形结构,保证路由查找速度稳定在Olog(n)。

  3. 支持hook,可以用来过滤参数,检查登录等。

  4. 支持根据handler参数列表自动获取变量,与hook结合使用,再也不用满篇写GET POST变量了。。。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

Why Use PHP? Advantages and Benefits Explained Why Use PHP? Advantages and Benefits Explained Apr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

See all articles