作为一个PHP开发者,现在是一个令人激动的时刻。每天有许许多多有用的库分发出来,在 上很容易发现和使用这些库。下面是我曾经遇到过最酷的24个库。你最喜欢的库没有在这个列表里面?那就在评论中分享吧!
1. Dispatch – 微框架
是一个PHP小框架。它并没有给你完整的MVC设置,但你可以定义URL规则和方法,以便更好组织应用程序。这对API、简单的站点或原型来说是完美的。
//包含库include 'dispatch.php'; // 定义你的路由get('/greet', function () { //渲染视图 render('greet-form');}); //post处理post('/greet', function () { $name = from($_POST, 'name'); // render a view while passing some locals render('greet-show', array('name' => $name));}); // serve your sitedispatch();
你可以匹配特定类型的HTTP请求和路径,渲染视图或做更多事情。如果你合并Dispatch和其他框架,那你就可以拥有一个相当强大并且轻量级的程序!
2. Klein – PHP快如闪电的路由
是另一款针对PHP5.3+版本的轻量级路由库。虽然它有一些比Dispatch冗长的语法,但它相当快。这有一个例子:
respond('/[:name]', function ($request) { echo 'Hello ' . $request->name;});
你也可以定制来指定HTTP方法和使用正则表达式作为路径。
respond('GET', '/posts', $callback);respond('POST', '/posts/create', $callback);respond('PUT', '/posts/[i:id]', $callback);respond('DELETE', '/posts/[i:id]', $callback); //匹配多种请求方法:respond(array('POST','GET'), $route, $callback); //你或许也想在相同的地方处理请求respond('/posts/[create|edit:action] /[i:id] ', function ($request, $response) { switch ($request->action) { // do something }});
对于小型项目来说这是很棒的,但当你把一个像这样的库用于大型应用时,你不得不遵守规矩,因为你的代码可能很快就变得不可维护。所以你最好搭配一个像 或者 这样完全成熟的框架。
3. Ham – 带缓存的路由库
也是一款轻量级的路由框架,但是它利用缓存甚至获得了更快的速度。它通过把任何I/O相关的东西缓存进XCache/APC。下面是一个例子:
require '../ham/ham.php';$app = new Ham('example');$app->config_from_file('settings.php');$app->route('/pork', function($app) { return "Delicious pork.";});$hello = function($app, $name='world') { return $app->render('hello.html', array( 'name' => $name ));};$app->route('/hello/ ', $hello);$app->route('/', $hello);$app->run();
这个库要求你至少安装了XCache和APC其中的一个,这可能意味着,在大多数主机提供商提供的主机上它可能用不了。但是如果你拥有一个安装它们其一的主机,或者你可以操控你的web服务器,你应该尝试这款最快的框架。
4. Assetic – 资源管理
是一个PHP的资源管理框架,用于合并和减小了CSS/JS资源。下面是例子。
use Assetic\Asset\AssetCollection;use Assetic\Asset\FileAsset;use Assetic\Asset\GlobAsset; $js = new AssetCollection(array( new GlobAsset('/path/to/js/*'), new FileAsset('/path/to/another.js'),)); //当资源被输出时,代码会被合并echo $js->dump();
以这种方式合并资源是一个好主意,因为它可以加速站点。不仅仅总下载量减小了,也消除了大量不必要的HTTP请求(这是最影响页面加载时间的两件事)
5. ImageWorkshop – 带层的图片处理
是一个让你操控带层图片的开源库。借助它你可以重定义尺寸、裁剪、制作缩略图、打水印或做更多事情。下面是一个例子:
// 从norway.jpg图片初始化norway层$norwayLayer = ImageWorkshop::initFromPath('/path/to/images/norway.jpg'); // 从watermark.png图片初始化watermark层(水印层)$watermarkLayer = ImageWorkshop::initFromPath('/path/to/images/watermark.png'); $image = $norwayLayer->getResult(); // 这是生成的图片! header('Content-type: image/jpeg');imagejpeg($image, null, 95); // We choose to show a JPG with a quality of 95%exit;
ImageWorkshop被开发用于使一些PHP中最通用的处理图片的案例简化,如果你需要一些更强大的东西,你应该看下 !
6. Snappy – 快照/PDF库
是一个PHP5库,可以生成快照、URL、HTML、PDF。它依赖于 binary(在Linux,Windows和OSX上都可用)。你可以像这样使用它们:
require_once '/path/to/snappy/src/autoload.php'; use Knp\Snappy\Pdf; //通过wkhtmltopdf binary路径初始化库$snappy = new Pdf('/usr/local/bin/wkhtmltopdf'); //通过把Content-type头设置为pdf来在浏览器中展示pdf header('Content-Type: application/pdf');header('Content-Disposition: attachment; filename="file.pdf"'); echo $snappy->getOutput('http://www.github.com');
要注意,你的主机提供商可能不允许调用外部二进制程序。
7. Idiorm – 轻量级ORM库
是个人之前在本网站教程中用过最喜爱的一款。它是一款轻量级的ORM库,一个建立在PDO之上的PHP5查询构造器。借助它,你可以忘记如何书写乏味的SQL:
$user = ORM::for_table('user') ->where_equal('username', 'j4mie') ->find_one();$user->first_name = 'Jamie';$user->save();$tweets = ORM::for_table('tweet') ->select('tweet.*') ->join('user', array( 'user.id', '=', 'tweet.user_id' )) ->where_equal('user.username', 'j4mie') ->find_many();foreach ($tweets as $tweet) { echo $tweet->text;}
Idiorm有一个姊妹库叫 , 是一个基于Idiorm的Active Record实现。
8. Underscore – PHP的工具腰带
是原始 的一个接口 – Javascript应用的工具腰带。PHP版本没有让人失望,而且支持了几乎所有原生功能。下面是一些例子:
__::each(array(1, 2, 3), function($num) { echo $num . ','; }); // 1,2,3, $multiplier = 2;__::each(array(1, 2, 3), function($num, $index) use ($multiplier) { echo $index . '=' . ($num * $multiplier) . ',';});// prints: 0=2,1=4,2=6, __::reduce(array(1, 2, 3), function($memo, $num) { return $memo + $num; }, 0); // 6 __::find(array(1, 2, 3, 4), function($num) { return $num % 2 === 0; }); // 2 __::filter(array(1, 2, 3, 4), function($num) { return $num % 2 === 0; }); // array(2, 4)
这个库也支持链式语法,这使得它更为强大。
9. Requests – 简单HTTP请求
是一个简化HTTP请求的库。如果你和我一样,几乎从来都记不住传递给Curl的各种各样的参数,那么它就是为你准备的:
$headers = array('Accept' => 'application/json');$options = array('auth' => array('user', 'pass'));$request = Requests::get('https://api.github.com/gists', $headers, $options); var_dump($request->status_code);// int(200) var_dump($request->headers['content-type']);// string(31) "application/json; charset=utf-8" var_dump($request->body);// string(26891) "[…]"
借助这个库,你可以发送HEAD、GET、POST、PUT、DELTE和PATCH HTTP请求,你可以通过数组添加文件和参数,并且可以访问所有相应数据。
10. Buzz – 简单的HTTP请求库
是另一个完成HTTP请求的库。下面是一个例子:
$request = new Buzz\Message\Request('HEAD', '/', 'http://google.com');$response = new Buzz\Message\Response(); $client = new Buzz\Client\FileGetContents();$client->send($request, $response); echo $request;echo $response;
因为它缺乏文档,所以你不得不阅读源码来获知它支持的所有参数。
11. Goutte – Web抓取库
是一个抓取网站和提取数据的库。它提供了一个优雅的API,这使得从远程页面上选择特定元素变得简单。
require_once '/path/to/goutte.phar'; use Goutte\Client; $client = new Client();$crawler = $client->request('GET', 'http://www.symfony-project.org/'); //点击链接$link = $crawler->selectLink('Plugins')->link();$crawler = $client->click($link); //使用一个类CSS语法提取数据$t = $crawler->filter('#data')->text(); echo "Here is the text: $t";
12. Carbon – DateTime 库
Carbon 是 DateTime API 的一个简单扩展。
printf("Right now is %s", Carbon::now()->toDateTimeString());printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); $tomorrow = Carbon::now()->addDay();$lastWeek = Carbon::now()->subWeek();$nextSummerOlympics = Carbon::createFromDate(2012)->addYears(4); $officialDate = Carbon::now()->toRFC2822String(); $howOldAmI = Carbon::createFromDate(1975, 5, 21)->age; $noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London'); $endOfWorld = Carbon::createFromDate(2012, 12, 21, 'GMT'); //总是以UTC对比if (Carbon::now()->gte($endOfWorld)) { die();} if (Carbon::now()->isWeekend()) { echo 'Party!';} echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2分钟之前'
13. Ubench – 微型基准库
Ubench 是一个用于评测PHP代码的微型库,可监控(代码)执行时间和内存使用率。下面是范例:
use Ubench\Ubench; $bench = new Ubench; $bench->start(); //执行一些代码 $bench->end(); //获取执行消耗时间和内存echo $bench->getTime(); // 156ms or 1.123secho $bench->getTime(true); // elapsed microtime in floatecho $bench->getTime(false, '%d%s'); // 156ms or 1s echo $bench->getMemoryPeak(); // 152B or 90.00Kb or 15.23Mbecho $bench->getMemoryPeak(true); // memory peak in bytes 内存峰值echo $bench->getMemoryPeak(false, '%.3f%s'); // 152B or 90.152Kb or 15.234Mb //在结束标识处返回内存使用情况echo $bench->getMemoryUsage(); // 152B or 90.00Kb or 15.23Mb
(仅)在开发时运行这些校验是一个好主意。
14. Validation – 输入验证引擎
声称是PHP库里最强大的验证引擎。但是,它能名副其实吗?看下面:
use Respect\Validation\Validator as v; //简单验证$number = 123;v::numeric()->validate($number); //true //链式验证$usernameValidator = v::alnum()->noWhitespace()->length(1,15);$usernameValidator->validate('alganet'); //true //验证对象属性$user = new stdClass;$user->name = 'Alexandre';$user->birthdate = '1987-07-01'; //在一个简单链中验证他的属性$userValidator = v::attribute('name', v::string()->length(1,32)) ->attribute('birthdate', v::date()->minimumAge(18)); $userValidator->validate($user); //true
你可以通过这个库验证你的表单或其他用户提交的数据。除此之外,它内置了很多校验,抛出异常和定制错误信息。
15. Filterus – 过滤库
是另一个过滤库,但它不仅仅可以验证,也可以过滤匹配预设模式的输出。下面是一个例子:
$f = Filter::factory('string,max:5');$str = 'This is a test string'; $f->validate($str); // false$f->filter($str); // 'This '
Filterus有很多内建模式,支持链式用法,甚至可以用独立的验证规则去验证数组元素。
16. Faker – 假数据生成器
是一个为你生成假数据的PHP库。当你需要填充一个测试数据库,或为你的web应用生成测试数据时,它能派上用场。它也非常容易使用:
//引用Faker 自动加载器require_once '/path/to/Faker/src/autoload.php'; //使用工厂创建来创建一个Faker\Generator实例$faker = Faker\Factory::create(); //通过访问属性生成假数据echo $faker->name; // 'Lucy Cechtelar'; echo $faker->address; // "426 Jordy Lodge // Cartwrightshire, SC 88120-6700" echo $faker->text; // Sint velit eveniet. Rerum atque repellat voluptatem quia ...
只要你继续访问对象属性,它将继续返回随机生成的数据。
17. Mustache.php – 优雅模板库
Mustache是一款流行的模板语言,实际已经在各种编程语言中得到实现。使用它,你可以在客户端或服务段重用模板。 正如你猜得那样, 是使用PHP实现的。
$m = new Mustache_Engine;echo $m->render('Hello { {planet}}', array('planet' => 'World!')); // "Hello World!"
建议看一下官方网站 查看更多高级的例子。
18. Gaufrette – 文件系统抽象层
是一个PHP5库,提供了一个文件系统的抽象层。它使得以相同方式操控本地文件,FTP服务器,亚马逊 S3或更多操作变为可能。它允许你开发程序时,不用了解未来你将怎么访问你的文件。
use Gaufrette\Filesystem;use Gaufrette\Adapter\Ftp as FtpAdapter;use Gaufrette\Adapter\Local as LocalAdapter; //本地文件:$adapter = new LocalAdapter('/var/media'); //可选地使用一个FTP适配器// $ftp = new FtpAdapter($path, $host, $username, $password, $port); //初始化文件系统$filesystem = new Filesystem($adapter); //使用它$content = $filesystem->read('myFile');$content = 'Hello I am the new content';$filesystem->write('myFile', $content);
也有缓存和内存适配器,并且随后将会增加更多适配器。
19. Omnipay – 支付处理库
是一个PHP支付处理库。它有一个清晰一致的API,并且支持数十个网关。使用这个库,你仅仅需要学习一个API和处理各种各样的支付处理器。下面是一个例子:
use Omnipay\CreditCard;use Omnipay\GatewayFactory; $gateway = GatewayFactory::create('Stripe');$gateway->setApiKey('abc123'); $formData = ['number' => '4111111111111111', 'expiryMonth' => 6, 'expiryYear' => 2016];$response = $gateway->purchase(['amount' => 1000, 'card' => $formData]); if ($response->isSuccessful()) { //支付成功:更新数据库 print_r($response);} elseif ($response->isRedirect()) { //跳转到异地支付网关 $response->redirect();} else { //支付失败:向客户显示信息 exit($response->getMessage());}
使用相同一致的API,可以很容易地支持多种支付处理器,或在需要时进行切换。
20. Upload – 处理文件上传
是一个简化文件上传和验证的库。上传表单时,这个库会校验文件类型和尺寸。
$storage = new \Upload\Storage\FileSystem('/path/to/directory');$file = new \Upload\File('foo', $storage);//验证文件上传$file->addValidations(array(//确保文件类型是"image/png" new \Upload\Validation\Mimetype('image/png'),//确保文件不超过5M(使用"B","K","M"或者"G") new \Upload\Validation\Size('5M')));//试图上传文件try {//成功 $file->upload();} catch (\Exception $e) {//失败! $errors = $file->getErrors();}
它将减少不少乏味的代码。
21. HTMLPurifier – HTML XSS 防护
是一个HTML过滤库,通过强大的白名单和聚集分析,保护你代码远离XSS攻击。它也确保输出标记符合标准。 (源码 上)
require_once '/path/to/HTMLPurifier.auto.php'; $config = HTMLPurifier_Config::createDefault();$purifier = new HTMLPurifier($config);$clean_html = $purifier->purify($dirty_html);
如果你的网站允许用户提交 HTML 代码,不修改就展示代码的话,那这时候就是用这个库的时候了。
22. ColorJizz-PHP – 颜色操控库
是一个简单的库,借助它你可以转换不同的颜色格式,并且做简单的颜色运算
use MischiefCollective\ColorJizz\Formats\Hex; $red_hex = new Hex(0xFF0000);$red_cmyk = $hex->toCMYK();echo $red_cmyk; // 0,1,1,0 echo Hex::fromString('red')->hue(-20)->greyscale(); // 555555
它已经支持并且可以操控所有主流颜色格式了
23. PHP Geo – 地理位置定位库
是一个简单的库,用于计算地理坐标之间高精度距离。例如:
use Location\Coordinate;use Location\Distance\Vincenty; $coordinate1 = new Coordinate(19.820664, -155.468066); // Mauna Kea Summit 茂纳凯亚峰$coordinate2 = new Coordinate(20.709722, -156.253333); // Haleakala Summit $calculator = new Vincenty();$distance = $calculator->getDistance($coordinate1, $coordinate2); // returns 128130.850 (meters; ≈128 kilometers)
它将在使用地理位置数据的app里出色工作。你可以试译 HTML5 Location API,雅虎的API(或两者都用,我们在 中这样做了),来获取坐标。
24. ShellWrap – 优美的命令行包装器
借助 库,你可以在PHP代码里使用强大的 Linux/Unix 命令行工具。
require 'ShellWrap.php';use \MrRio\ShellWrap as sh; //列出当前文件下的所有文件echo sh::ls(); //检出一个git分支sh::git('checkout', 'master'); //你也可以通过管道把一个命令的输出用户另一个命令//下面通过curl跟踪位置,然后通过grep过滤’html’管道来下载example.com网站echo sh::grep('html', sh::curl('http://example.com', array( 'location' => true))); //新建一个文件sh::touch('file.html'); //移除文件sh::rm('file.html'); //再次移除文件(这次失败了,然后因为文件不存在而抛出异常)try { sh::rm('file.html');} catch (Exception $e) { echo 'Caught failing sh::rm() call';}
当命令行里发生异常时,这个库抛出异常,所以你可以及时对之做出反应。它也可以通过管道让你一个命令的输出作为另一个命令的输入,来实现更强的灵活性。
包管理Package Management
Libraries for package and dependency management.
- / – A package and dependency manager.
- – A multi framework Composer library installer.
Libraries related to package management.
- – A static Composer repository generator.
- – A library to check your Composer environment at runtime.
- – A Composer class aliasing library.
- – A parsing and comparison library for semantic versioning.
- – A library to convert from underscores to namespaces.
- – A library to install patches using Composer.
框架
Web 开发框架.
- – A framework comprised of individual components.
- – A Rapid Application Development (RAD) bundle for Symfony 2.
- – Another framework comprised of individual components.
- – A simple PHP framework.
- – Another framework of components.
- – A framework of independent components.
- – A framework implemented as a C extension.
框架组件
Web 开发框架的独立组件.
- – The components that make Symfony2.
- – The components that make ZF2.
- – A package of PHP 5.4 components.
微框架Micro Frameworks
微框架和路由器routers.
- – A micro framework built around Symfony2 components.
- – A project skeleton for Silex.
- – Another project skeleton for Silex.
- – A web debug toolbar for Silex.
- – A library of stackable middleware for Silex/Symfony.
- – Another simple micro framework.
- – A skeleton for Slim.
- – A collection of custom views for Slim.
- – A collection of custom middleware for Slim.
- – A mico framework for building REST APIs.
- – A fast routing library.
- – Another fast routing library.
- – A powerful and easy-to-use micro framework.
内容管理系统Content Management Systems
现代内容管理系统Modern content management systems.
- – A simple CMS built with Silex and Twig.
模板Templating
库和工具,模板和词法。
- – A comprehensive templating language.
- – A template fragment cache library for Twig.
- – A PHP implementation of the Mustache template language.
- – Another PHP implementation of the Mustache template language.
- – A PHP implementation of the HAML template language.
- – A native PHP templating library.
- – A lightweight template parser.
静态网站生成器Static Site Generators
工具为预先处理的内容来生成网页。
- – A tool that converts Markdown and Twig into static HTML.
- – Another tool that converts Textile, Markdown and Twig into HTML.
HTTP
Libraries for working with HTTP and scraping websites.
- – A HTTP client.
- – Another HTTP client.
- – A simple HTTP library.
- – A simple web scraper.
- – A library for recording and replaying HTTP requests.
URL
Libraries for parsing URLs.
- – A URL manipulation library.
- – A domain suffix parser library.
Email
用于收发邮件的库.
- – A mailer solution.
- – Another mailer solution.
- – An IMAP library.
- – An email reply parser library.
- – A library for email services such as , and .
Files
用于文件操作和MIME类型探测.
- – A filesystem abstraction layer.
- – Another filesystem abstraction layer.
- – A library to determine internet media types.
- – A library that parses Apache MIME types.
- – A MIME detection library.
- – Another MIME detection library.
- – A resource tracking library.
- – A library for locating files in large projects.
- – A wrapper for the video library.
Streams
Libraries for working with streams.
- – A simple object-orientated stream wrapper library.
Dependency Injection
实现了依赖注入设计模式库。Libraries that implement the dependency injection design pattern.
- – A tiny dependency injection container.
- – Another dependency injection container.
- – Another flexible dependency injection container.
- – A dependency injection implementation using annotations.
- – A common interface to dependency injection containers and service locators.
Imagery
图片处理库Libraries for manipulating images.
- – An image manipulation library.
- – Another image manipulation library.
- – Another image manipulation library.
- – A library to extract GIF animation frame information.
- – A library to create GIF animations from multiple images.
- – A library for embedding text into images.
- – A library for extracting colours from images.
Testing
单元测试相关库。Libraries for testing codebases and generating test data.
- – A unit testing framework.
- – A database testing library for PHPUnit.
- – A parallel testing library for PHPUnit.
- – A design by specification unit testing library.
- – A full stack testing framework.
- – A simple testing library.
- – A mock object library for testing.
- – Another mock object library for testing.
- – Yet another mock object library for testing.
- – A continuous testing server library.
- – A fake data generator library.
- – Another fake data generator library.
- – An expressive fixture generation library.
- – A behaviour driven development (BDD) testing framework.
- – Another behaviour driven development testing framework.
- – Web acceptance testing.
- – A library for mocking HTTP requests in unit tests.
- – A virtual filesystem stream wrapper for testing.
- – A modern load test library written in Python.
- – A continuous integration platform.
- – An open source continuous integration platform for PHP.
Documentation
生成项文档的库。Libraries for generating project documentation.
- – An API documentation generator.
- – Another API documentation generator.
- – A documentation generator.
Security
Libraries for generating secure random numbers, encrypting data and scanning for vulnerabilities.
- – A standards compliant HTML filter.
- – A library for generating random numbers and strings.
- – A library that generates random numbers using .
- – A PHP security library.
- – A compatibility library for the new PHP 5.5 password functions.
- – A portable password hashing framework.
- – A library for generating and validating passwords.
- – A password policy library for PHP and JavaScript.
- – A library for validating and upgrading password hashes.
- – A pure PHP secure communications library.
- – A simple encrypted key-value storage library.
- – A structured PHP security layer.
- – An experimental object orientated SSH wrapper library.
- – A tool that scans PHP INI files for security.
- – A web tool to check your Composer dependecies for security advisories.
- – An integrated penetration testing tool for web applications.
Code Analysis
库和工具来分析,解析和操作的代码库。Libraries and tools for analysing, parsing and manipulation codebases.
- – A PHP parser written in PHP.
- – A PHP VM implementation in PHP.
- – A PHP sandbox environment.
- – A set of tools for lexical and syntactical analysis.
- – A library that scans code for bugs, sub-optimal code, unused parameters and more.
- – A library that detects PHP, CSS and JS coding standard violations.
- – A library that detects copied and pasted code.
- – A library for analysing PHP code to find bugs and errors.
- – A coding standard fixer library.
- – A library for analysing and modifying PHP Source Code.
- – A command line utility for refactoring PHP code.
- – A simple micro benchmark library.
- – An annotation based benchmark framework.
- – A code analysis tool using Graph Theory.
- – A debugging toolbar.
- – A web debugging console.
- – Another web debugging console using Google Chrome.
- – An interactive PHP debugger.
- – A web tool to scrutinise PHP code.
项目构建和自动化工具。Project build and automation tools.
- – A simple PHP build tool.
- – A simple project automation tool.
- – A rake PHP clone library.
- – A utility to build PHAR files.
Asset Management
Tools for managing, compressing and minifying website assets.
- – An asset manager pipeline library.
- – Another asset manager pipeline library.
- – An asset optimiser library.
- – A JavaScript minifier library.
Geolocation
Libraries for geocoding addresses and working with latitudes and longitudes.
- – A geocoding library.
- – A library of geo-related tools.
- – A simple geo library.
- – A GeoJSON implementation.
Date and Time
日期和时间处理库。Libraries for working with dates and times.
- – A simple DateTime API extension.
- – Another DateTime API extension.
- – A calendar management library.
Event
Libraries that are event-driven or implement non-blocking event loops.
- – An event driven non-blocking I/O library.
- – A reactive extension library.
- – A web socket library.
- – Another web socket library.
- – An event source library.
- – An event dispatcher library.
- – Another event dispatcher library.
Logging
Libraries for generating and working with log files.
- – A comprehensive logger.
E-commerce
Libraries and applications for taking payments and building online e-commerce stores.
- – A framework agnostic multi-gateway payment processing library.
- – A payment abstraction library.
- – An open source e-commerce solution.
- – Another open source e-commerce solution.
- – A PHP implementation of Fowler's money pattern.
PDF
PDF文件操作类库。Libraries and software for working with PDF files.
- – A PDF and image generation library.
- – A tool to convert HTML to PDF.
ORM and Datamapping
对象-关系映射库。Libraries that implement object-relational mapping or datamapping techniques.
- – A comprehensive DBAL and ORM.
- – A migration library for Doctrine.
- – A collection of Doctrine behavioural extensions.
- – A fast ORM.
- – The Laravel 4 ORM.
- – A nested set implementation for Eloquent.
- – A MySQL datamapper ORM.
- – A lightweight, configuration-less ORM.
- – A PHP Active Record implementation.
- – A minimalist database library.
- – An Object Model Manager for PostgreSQL.
- – A migration management library.
- – Another migration management library.
- – Another database migration library.
NoSQL
Libraries for working with "NoSQL" backends.
- – A MongoDB query builder library.
- – A MongoDB abstraction library.
- – A feature complete Redis library.
Queue
Libraries for working with event and task queues.
- – A Beanstalkd client library.
- – A pure PHP AMQP library.
- – A RabbitMQ pattern library.
- – A multibackend abstraction library.
Search
Libraries and software for indexing and performing search queries on data.
- – The official client library for .
- – A client library for ElasticSearch.
- – A client library for .
Command Line
Libraries for building command line utilities.
- – A tiny PHP REPL.
- – Another PHP REPL.
- – A command line opt parser.
- – Another command line opt parser.
- – Another simple command line opt parser.
- – Another command line opt parser.
- – A library to calculate cron run dates.
- – A simple command line wrapper library.
- – Another command line library.
- – A library for running commands in parallel on multiple remote machines.
Authentication
Libraries for implementing authentications schemes.
- – A framework agnostic authentication & authorisation library.
- – A library for social network authentication.
- – A multi-provider authentication framework.
- – An OAuth2 authentication server, resource server and client library.
- – Another OAuth library.
- – A Twitter OAuth library.
- – A fully tested Twitter SDK.
- – A Hawk HTTP authentication library.
Markup
Libraries for working with markup.
- – A lightweight markup parser library.
- – A Markdown parser.
- – Another Markdown parser.
- – Another Markdown parser.
- – Another Markdown parser that supports Github flavoured Markdown.
- – An HTML5 parser and serializer library.
Text and Numbers
Libraries for parsing and manipulating text and numbers.
- – An ANSI to HTML5 convertor library.
- – A portable library for working with UTF-8 strings.
- – Another UTF-8 string library.
- – A string manipulation library with multibyte support.
- – A library for working with numbers.
- – A library for working with large numbers.
- – A library for manipulating and converting colours.
- – A library for generating UUIDs.
- – A library to convert strings to slugs.
- – A PHP port of Django's URLify.js.
- – A text manipulation library.
- – A library for converting between units of measure.
- – Another library for converting between units of measure.
- – A library for formatting SQL statements.
- – A simple byte conversion library.
- – A library for parsing user agent strings.
- – A PHP implementation of Google's phone number handling library.
Filtering and Validation
用于过滤和校验数据。Libraries for filtering and validating data.
- – A simple PHP filtering library.
- – A simple validation library.
- – Another validation library.
- – A library for handling file uploads and validation.
- – An annotation filtering library.
- – A schema validation library that supports YAML, JSON and XML.
REST and API
Libraries and web tools for developing REST-ful APIs.
- – An API builder built with Zend Framework 2.
- – A HATEOAS REST web service library.
- – A Hypertext Application Language (HAL) builder library.
- – A content negotiation library.
Caching
数据缓存库。Libraries for caching data. - – A caching library (part of Doctrine).
- – Another library for caching.
Data Structure and Storage
Libraries that implement data structure or storage techniques.
- – A library of data structures.
- – A simple collections library.
- – A library for serialising and de-serialising data.
- – A library for object storage.
- – A library for converting complex data structures to JSON output.
Notifications
Libraries for working with notification software.
- – A notification library (e.g., Growl).
- – A library for handling push notifications.
- – A standalone library for device push notifications.
- – A lightweight notification library.
Deployment
- – A deployment tool for PHP applications.
- – A fast and easy deployer for the PHP world.
Third Party APIs
Libraries for accessing third party APIs.
- – The official PHP AWS SDK library.
- – A stream wrapper library for Amazon S3.
- – The official Stripe PHP library.
- – The official Campaign Monitor PHP library.
- – A library to interface with the Digital Ocean API.
- – A library to interface with the Github API.
- – Another library to interface with the Github API.
- – A library to interface with Twitter's OAuth workflow.
- – A library to interact with Twitter's REST API.
- – The official PHP Dropbox SDK library.
- – The official Twilio PHP REST API.
Miscellaneous
Useful libraries or tools that don't fit in the categories above.
- – A process forking library.
- – A JSON lint utility.
- – A library for validating JSONP callbacks.
- – A menu library.
- – A pagination library.
- – A simple stateless production rules engine.
- – A CQRS (Command Query Responsibility Separation) library.
- – A library that makes dealing with SSL suck less.
- An option type library.
- – A simple metrics API library.
- – A library for parsing VCard and iCalendar objects.
- – An annotations library (part of Doctrine).
- – A pretty error handling library.
- – A simple PHP finite state machine.
- – A dumper library.
- – A deployer library.
- – A library for running time consuming tasks.
- – A function composition library.
- – A library that allows Closures to be serialized.
- – A remote service executor library.
- – A PHP port of the Underscore JS library.
- – A PHP library for iOS PassBook.
- – A PHP expression language.
- – A library for versioning and releasing software.
- – A configuration manager.
- – An opengraph library.
- – A library for extracting web media.
- – An Oembed consumer library.
- – A Graphviz library.
- – A simple Monad library.
- – A regular expression building library.
- – A library for redefining userland functions.
- – Evolutionary language transformation.
- – A repository of software patterns implemented in PHP.
- – A PHP port of the Java Content Repository (JCR).
- – A functional programming library.
- – A library for optimising autoloading.
- – A library for country and subdivision data.
- – A library for simplifying accessors.
- – A TCP/IP stack proof of concept written in PHP.
- – A PHP wrapper around .
- – A library for moving code.
- – A library that provides iteration primatives using generators.
- – A Lambda calculus interpreter in PHP.
- – A list of all countries with names and ISO 3166-1 codes.
- – A library for playing with the Raspberry PI's GPIO pins.
Development Software
Software for creating a development environment.
- – A package manager for OSX.
- – A PHP tap for HomeBrew.
- – A PHP installer for OSX.
- – A Virtual Machine, Runtime and JIT for PHP by Facebook.
- – A portable development environment utility.
- – A radically simple orchestration framework.
- – A server automation framework and application.
- – A systems integration framework.
- – An infrastructure management tool.
- – A PHP version manager and installer.
- – Another PHP version manager.
- – Another version manager.
- – Another PHP version installer.
- – A general web development tool.
- – A command line alternative to cURL written in Python.
- – A server backup tool written in Ruby.
Web-based tools.
- – A web tool for building PHP development virtual machines.
- – Another web tool for building PHP development virtual machines.
- – An online PHP shell.
- – A database version control application.
- – An application for managing queueing backends.
- – A tool for downloading Composer packages as a zip file.
- – A web tool for capturing and viewing emails.
Resources
Various resources, such as books, websites and articles, for improving your PHP development skills and knowledge.
Websites
Useful web and PHP-related websites and newsletters.
- – A PHP best practice quick reference guide.
- – A PHP best practice guide.
- – A weekly PHP newsletter.
- – A guide to PHP security.
- – A book about the PHP internals.
- – The PHP Framework Interoperability Group.
- – An open software security community.
- – A web security community resource.
- – An advent calendar for web developers.
- – A website of shared knowledge for the open web.
- – A resource for open web HTML5 developers.
- – A video series by Anthony Ferrara.
Books
Fantastic books and e-books.
- – An ebook about scaling PHP applications by Steve Corona.
- – A book about unit testing with PHPUnit by Chris Hartjes.
- – A book about object-orientated PHP by Brandon Savage.
- – A book about catching PCNTL signals in CLI scripts by Cal Evans.
- – A book about computation theory by Tom Stuart.
- – A book about the Linux command line by William Shotts.
Web Reading
General web-development-related reading materials.
- – A PHP security cheatsheet.
- – An article about cookies and security.
- – An article about using HTTPS correctly with login forms.
- – An article explaining how TLS/SSL secures your connection.
- – An article on how to build a secure remember me feature.
- – An article about HTTP cache headers.
- Beyond Series – A series of articles about programming by Anthony Ferrara.
- – A website explaining semantic versioning.
- – A series of Git tutorials.
- – A series of Mercurial tutorials.
PHP Reading
PHP-releated reading materials.
- – A series of articles on how to make your own PHP framework by Fabien Potencier.
- – An article about correct BCrypt implementation.
- – An article on preventing CSRF attacks.
- – An article about the BREACH hack and CSRF tokens.
- – An article about lambda functions and closures.
- – An article about using the unix environment helper.
- – A Composer primer.
- – An article about Composer versioning.
- – An article about Composer stability flags.
- – An article about PHP taking ideas from other language.
- – An article about generating random numbers.
- – An article about preventing XSS.
- – An article about the pros and cons of PHP.
- – An article about the PHP language and ecosystem.
PHP Internals Reading
Reading materials related to the PHP internals or performance.
- – The home of PHP RFCs (Request for Comments).
- – An article about print and echo performance.
- – An article ternary performance.
- – An article about performance of single and double quoted strings.
- – An article about internal ZVALs.
- – An article about string internals.
- – An article about opcodes.
- – A detailed StackOverflow answer about foreach.
- – An article about the internals of foreach.
- – An article about array internals.
- – An article about evaluation order in PHP.
- PHP Source Code for Developers: – A series about the PHP source code.
- Collecting Garbage: – A series about the PHP garbage collection internals.