Siler interview: Making PHP easy and enjoyable
Siler is a set of general purpose high-level abstractions aiming an API for declarative programming in PHP using the “keep it simple, stupid” principle. Its latest release, Siler 1.7.2 is here and we spoke to Leo Cavalcante about the library and what his top three favorite new features are. Let’s take a look.
JAXenter: Please give us an overview: What is siler?
Leo Cavalcante: Siler is a library to make things simpler using the KISS principle. Its goal is to make PHP easy and enjoyable like calling functions in files without compromising code quality.
JAXenter: How does it work?
Leo Cavalcante: It achieves that by favoring the functional paradigm approach to programming, making those functions as pure as possible, being strict about type-safety and exposing a declarative API.
It is also worth to mention that Siler works on a peer-dependency premise, you install just what and when you need, Siler itself has 0 dependencies (no-dev).
JAXenter: What are the advantages for developers who use this tool?
Leo Cavalcante: Pragmatic and easy. It’s like pure PHP, but with nicely arranged, unified and namespaced functions. You can skip tons of unused files, misleading xml/yaml configurations and enforced architectures.
It provides straightforward APIs for routes, functional programming, logging, Twig, mailing and mainly: Swoole, Ratchet, Laminas Stratigility (PSR-7/15), GraphQL and now gRPC.
JAXenter: Siler 1.7.2 has been released: Which three features are among your personal highlights?
Leo Cavalcante: 1. The gRPC server capability, it’s on an early stage, only unary request-response for now, but I like the potential (example) since Siler’s lightweight and simplicity makes it a good call for micro-services.
2. The new functional constructs. They are helping me a lot to make a functional/declare code:
use Siler\Functional as λ; // Just to be cool, don't use non-ASCII identifiers ;) $pipeline = λ\pipe([ λ\lmap(fn (string $s): string => trim($s)), λ\lfilter(λ\not(λ\equal('baz'))), λ\non_empty, λ\ljoin(',') ]); echo $pipeline(['foo', ' ', 'bar', 'baz']); // foo,bar
3. And the typed array_gets avoids more type annotations for PhpStorm’s and Psalm’s static analyzers, it helps them infer what you expect in an associative array.
JAXenter: What plans do you have for the future of the tool?
Leo Cavalcante: For the near future: GraphQL’s Custom Directives are being discussed here.
And I’m planning something for databases/persistence, there are good players like Eloquent and Doctrine, but I’m not keen to ORMs, especially ActiveRecord ones.
I’m drafting an implementation that is between a DataMapper and a TableGateway, fully convention-over-configuration and adapted for Swoole’s MySQL and Postgres Coroutine clients, beyond PDO, but just started this week, nothing relevant to show yet.
Thank you very much!