I’m assuming you already know what is GraphQL and Swoole, so what about getting started right straight to the code, shall we?

What you maybe doesn’t know yet is about Siler! It is a set of general purpose high-level abstractions aiming an API for declarative programming in PHP.
With Siler we can abstract way “hard” parts from popular tools like GraphQL and recently Swoole. And yes, I’m the author, so feel free to file any issues or make any questions about it.

“Talk is cheap, show me the code”. Let’s go!

I want to make it simple as possible so…


When I’m not in front of a “soup of colored letters” (people say this when they see my screen on VS Code) or “jumpy green text” (yeah, this one is for the terminal); I like to play and study music! Diving into my journey on F#, this is my attempt to mix this new and old passions.

Some basic music context

As you maybe already know, music has a lot of ways to get things done, harmonic fields, chord progression, scales and much more. But let’s keep this simple, everybody knows about a least one scale, the Major scale:

This one in particular…


I have just a couple years in functional programming, just a couple weeks in F# and no background or experience with .NET, so don’t take this as a reference from an expert, it’s just me documenting what I’ve learned so far.

You can start by building a very raw-vanilla-bare-bones HTTP server using the HttpListener from .NET, but is very low-level in terms of having few abstractions, like: you have to write on stream buffers to output something.

There is ASP.NET Core, but is is very object-oriented, it’s constructions aren’t functional and hey, we’re using F# for a reason, right?

Freya


One the of the hardest things in development - IMHO - after naming, is handling State, at least handling it reactively without overs (over-building, over-rendering, over-painting and overhead!).

Let’s get started!

No secret:

flutter create geo_tag_diary

Open it in your favorite editor, I personally like VSCode, so code geo_tag_diary, then add flutter_redurx in your dependencies key at pubspec.yaml. Let you editor get the dependencies again or run in the project folder: flutter packages get.

dependencies:
flutter_redurx:
flutter:
sdk: flutter

Now let’s create a very basic app just to see it working in the device/emulator/simulator (you name it).

Create a lib/app.dart


É comum as pessoas defenderem que hash não é criptografia; fazem isso veemente a ponto de ridicularizar quando leem algo como “Fiz criptografia com MD5”. É tão errado assim falar isso?

Você já viu algum artigo em inglês comentando algo do tipo? Algo como “Hash is not Cryptography”? Agora pesquisa por “Hash não é Criptografia”. Interessante, não é? Parece que é uma constatação apenas brasileira.

Essa observação me fez levantar a hipótese de que a culpa é da tradução. …


I used to love everything about object oriented programming, ignoring everything else, when I finally got it, I thought that every piece of software should be developed using OO and if it is not, it is wrong.

Meanwhile, I was very happy studying JavaScript, then I got hit by this Functional Programming thing. The first common thought was: is it programming with functions? Yes and no. Found out that it is about functions, but it shouldn’t be imperative code inside functions, it is way beyond. …


Here we are going to build a chat app using:

  1. Ratchet, for WebSockets abstraction.
  2. Siler, for Ratchet abstraction.
  3. React, for UI/DOM (HTML) abstraction.

Since neither Siler or Ratchet require us to have a predefined folder structure, we can start working with create-react-app then nicely mix our back-end code within.

$ create-react-app $(codename --slug)

If you have naming problems like me, check out Intel Codenames Picker.
Here I got downey (DowneyChat looks good), so let’s cd to it:

$ cd downey

Here we magically got a running React app with its dependencies and front-end development facilities already loaded. …


Zero config. Zero boilerplate. Zero unnecessary stuff.

Siler is github.com/leocavalcante/siler
RedBeanPHP is github.com/gabordemooij/redbean

Let’s start!

Make a new directory and enter it

λ mkdir siler-n-redbean-rocks && cd siler-n-redbean-rocks

Bring the kids to the playground:

λ composer require leocavalcante/siler dev-master \
&& composer require gabordemooij/redbean dev-master

Let’s type!

Create an index.phpfile.

<?phprequire_once __DIR__.'/vendor/autoload.php';use Siler\Route;
use RedBeanPHP\Facade as R;
R::setup('sqlite:dbfile.db');
Route\resource('/beers', 'api/beers');

Simple like that

It requires Composer’s auto loader, setups RedBean to use SQLite (awesome for testing and prototyping) and declares a new Siler resource. …


Right, for those who have already read ES6 Multiple Inheritance and More fun(ctions) with factories and assignments! saw my triathlete sample codes, but now it had evolved to Functional Programming.

Not much to talk about it. You probably now what FP is and if you don’t, I’ll not be explaining it right now.

Here is it.

I really encourage you to see the previous mentioned samples to get it. And you can see this sample above running on Babel Repl:

I’m using this “one letter arguments” ’cause I’m on my to Go, so.


Vi uns 3 ou 4 posts nessas últimas semanas sobre: “o mundo tá f#da, o hype tá complexo”. Certo, não exatamente com essas palavras, mas nessa pegada. Posts falando sobre como as novidades que temos visto são “coisas difíceis demais”, principalmente no front-end.

Concordo que 1 framework JavaScript por semana não é legal, mas é dessas que surgem coisas interessantes como React e que surgiu Ember, Angular e Backbone, desses 1 por semana, alguns ganham popularidade.

React tem sido a menina dos olhos ultimamente, mas também tem sido bem controverso, as pessoas estão há gerações (da Internet) aprendendo que HTML…

Leo Cavalcante

Living-standards of my ideias and opinions. Programming, Music, Tech & Arts.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store