Skip to content

Instantly share code, notes, and snippets.

@ianrodrigues
ianrodrigues / estados-cidades.json
Created September 21, 2016 16:52 — forked from letanure/estados-cidades.json
JSON estados cidades
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@ianrodrigues
ianrodrigues / .php_cs
Created January 4, 2017 19:17
Laravel 5.3 PHP CS Fixer example.
<?php
use Symfony\CS\Config\Config;
use Symfony\CS\FixerInterface;
use Symfony\CS\Finder\DefaultFinder;
$fixers = [
'blankline_after_open_tag',
'braces',
'double_arrow_multiline_whitespaces',
@ianrodrigues
ianrodrigues / default
Created March 20, 2017 16:31 — forked from ghalusa/default
nginx default configuration file (ubuntu path: /etc/nginx/sites-available/default) with conversions of .htaccess environment variables and mod_rewrite logic, along with parameters supporting a fastcgi-based php setup
server {
listen 80;
root /var/www/YOUR_DIRECTORY;
index index.php index.html index.htm;
###################################################
# Change "yoururl.com" to your host name
server_name yoururl.com;
@ianrodrigues
ianrodrigues / .gitlab.ci.yml
Created May 2, 2017 10:51 — forked from yannhowe/.gitlab.ci.yml
.gitlab.ci.yml for SSH with private key.
# Image neeeds to have ssh-client
image: docker:git
services:
- docker:dind
stages:
- staging
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
@ianrodrigues
ianrodrigues / 1.How to easily implement a REST API with oAuth2 presentation.md
Created September 11, 2017 12:45 — forked from lologhi/1.How to easily implement a REST API with oAuth2 presentation.md
Symfony2 : How to easily implement a REST API with oAuth2 (for normal guys)

It's still a work in progress...

Intro

As William Durand was recently explaining in his SOS, he "didn't see any other interesting blog post about REST with Symfony recently unfortunately". After spending some long hours to implement an API strongly secured with oAuth, I thought it was time for me to purpose my simple explanation of how to do it.

Ok, you know the bundles

You might have already seen some good explanation of how to easily create a REST API with Symfony2. There are famous really good bundles a.k.a. :

@ianrodrigues
ianrodrigues / README.md
Created September 11, 2017 12:49 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

@ianrodrigues
ianrodrigues / paginate.php
Created December 19, 2017 13:15 — forked from vluzrmos/paginate.php
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
@ianrodrigues
ianrodrigues / responsive-video.css
Created March 16, 2018 19:33 — forked from jaicab/responsive-video.css
Pure CSS solution for embed videos with an aspect ratio of 16:9
.video-container {
position: relative;
padding-bottom: 56.25%; /*16:9*/
padding-top: 30px;
height: 0;
overflow: hidden;
}
.video-container iframe,
.video-container object,
@ianrodrigues
ianrodrigues / Schema.graphql
Created April 24, 2020 19:30 — forked from ThisIsMissEm/Schema.graphql
Form Validation as a Result Union
mutation updateUser(
details: UpdateUserInput!
): UpdateUserResult
union UpdateUserResult =
UpdateUserSuccess |
FormValidationError
type UpdateUserSuccess {}
@ianrodrigues
ianrodrigues / bash_curl_loop
Created June 22, 2020 16:04 — forked from ceme/bash_curl_loop
bash curl loop
while true; do sleep 1; curl http://www.google.com; echo -e '\n\n\n\n'$(date);done