Tag Archives: Symfony

Symfony 上的 API framework。但如果不是用 Symfony 呢?這時候就可以考慮用 neomerx/json-api 這套按 標準 (http://jsonapi.org/) 實作的 PHP library。
這 library 包含了其獨立的 encoder、schema(重造輪子?),它 Github 上的 wiki 有較詳細的 document。

A good API is one of most effective ways to improve the experience for your clients. Standardized approaches for data formats and communication protocols increase productivity and make integration between applications smooth.

This framework agnostic package implements JSON API specification version v1.0 and helps focusing on core application functionality rather than on protocol implementation. It supports document structure, errors, data fetching as described in JSON API Format and covers parsing and checking HTTP request parameters and headers. For instance it helps to correctly respond with Unsupported Media Type (HTTP code 415) and Not Acceptable (HTTP code 406) to invalid requests. You don’t need to manually validate all input parameters on every request. You can configure what parameters are supported by your services and this package will check incoming requests automatically. It greatly simplifies API development and fully support specification. In particular

    • – Resource attributes and relationships

 

    • – Polymorphic resource data and relationships

 

    • – Compound documents with inclusion of related resources (circular resource references supported)

 

    • – Meta information for document, resources, errors, relationship and link objects

 

    • – Parsing HTTP Accept and Content-Type headers in accordance with RFC 7231

 

    • – Parsing parameters for pagination, sorting and filtering

 

    • – Sparse fieldsets and customized included paths

 

    – Errors

Clients built around JSON API are able to take advantage of its features around efficiently caching responses, sometimes eliminating network requests entirely.

https://github.com/neomerx/json-api

Doctrine ORM Good Practices and Tricks

《Doctrine ORM Good Practices and Tricks》

Doctrine 是 PHP 上的一套 ORM,如果有用 Symfony 的話大概會聽過這名字,因為兩者整合得很好。(註:Doctrine 是可以獨立使用,跟 Symfony 乃兩個不同 project)
寫 backend 用得最多就是 database ,而 Doctrine 使用上雖邏輯清楚,但談不上簡單易用。若有不妥,更往往成為網站速度的殺手。
這段 video 講解了各種 Doctrine 的功能優劣、技巧要點,推薦給 Doctrine 的資深用家。
PS: Doctrine 的設計乃源自 Java 上的一套 Hibernate ORM。
PS2: Propel 是另一套 PHP 上流行 ORM,但它是用 ActiveRecord 的寫法,比較簡單。

https://player.vimeo.com/video/134178140

Symfony achieves 100% PHP7 compatibility

Symfony achieves 100% PHP7 compatibility

PHP7, the new version of the programming language Symfony is built with, will be released at the end of the year. The recent release of its third beta has brought us another step closer to the final stable release.

During these last past months, we’ve been working very hard to achieve full PHP7 compatibility. This effort accelerated during the past weeks and we’re glad to announce that all Symfony maintained branches are now 100% compatible with PHP7.

http://symfony.com/blog/symfony-achieves-100-php7-compatibility

Symfony2 and RabbitMQ: Lessons learned

《Symfony2 and RabbitMQ: Lessons learned》

最近在用 RabbitMQ,一切安好,只是一直碰到 “MySQL server has gone away” 的問題。貌似是相當常見的問題。這篇文章好像有解決方法…

Last year we introduced RabbitMQ into our stack at Waarneembemiddeling.nl. We were in desperate need of a worker queue and after fiddling around with Gearman, Beanstalkd and RabbitMQ we made our choice: RabbitMQ it will be.

Now there’s quite some information to be found on RabbitMQ and how to use it, but a lot of things you have to find out yourself. Questions like:

    • – what happens to messages on the queue after a service restart?

 

    • – what happens to messages on the queue after a reboot?

 

    • – how do we notice that a worker crashed?

 

    • – what happens to my message when the consumer dies while processing?

 

    etc.

https://blog.vandenbrand.org/2015/01/09/symfony2-and-rabbitmq-lessons-learned/