search
HomeBackend DevelopmentPHP Tutorialapache - 大家自己写过哪些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>

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>

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
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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 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: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 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.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 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.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

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

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

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

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools