Skip to content

Instantly share code, notes, and snippets.

View dunglas's full-sized avatar

Kévin Dunglas dunglas

View GitHub Profile
@dunglas
dunglas / gist:4da2026f34bf7f18e1db955ef8a9b417
Last active December 18, 2020 14:20
Proposal: new public API for API Platform and the TypeScript library
<?php
// Verbose
#[Get] // path defaults to /users
#[Get("/company/{companyId}/users")]
#[Post] // path defaults to /users
#[Post("/company/{companyId}/users)]
class Users extends \ArrayObject
{
@dunglas
dunglas / Working on API Platform during #SymfonyHackday.md
Last active December 5, 2020 08:45
Working on API Platform during #SymfonyHackday
@dunglas
dunglas / uri-template.php
Created May 25, 2020 18:53
URI Template test in PHP
<?php
require __DIR__.'/vendor/autoload.php';
use Rize\UriTemplate;
$uri = new UriTemplate('', ['version' => 1.1]);
var_dump($uri->extract('https://example.net/{ip}', 'https://example.net/2001:db8::35'));
var_dump($uri->extract('https://example.net/{ip}', 'https://example.net/2001:db8::35', true));
@dunglas
dunglas / uri-template-test.rb
Created May 25, 2020 18:36
URI Template test in Ruby
require "addressable/template"
template = Addressable::Template.new(
"https://example.net/{ip}"
)
uri = Addressable::URI.parse(
"https://example.net/2001:db8::35"
)
puts template.extract(uri).inspect
@dunglas
dunglas / DemoApplication.java
Created May 25, 2020 18:04
URI Template test in Java
package com.example.demo;
import java.util.Map;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriTemplate;
@dunglas
dunglas / Program.cs
Created May 25, 2020 18:03
URI Template test in C#
using System;
using Tavis.UriTemplates;
public class Program
{
public static void Main()
{
var ut = new UriTemplate("https://example.net/{ip}");
var p = ut.GetParameters(new Uri("https://example.net/2001:db8::35"));
Console.WriteLine(p["ip"]);
@dunglas
dunglas / Dunglas_CLA
Last active April 20, 2020 22:37 — forked from CLAassistant/SAP_CLA
Kévin Dunglas Individual Contributor License Agreement
### Kévin Dunglas Individual Contributor License Agreement
Thank you for your interest in contributing to open source software projects (“Projects”) made available by Kévin Dunglas or its affiliates. This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to Kévin Dunglas in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact dunglas+cla@gmail.com.
You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.
**Copyright License.** You hereby grant, and agree to grant, to Kévin Dunglas a non-exclusive,
#!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\HttpClient\CurlHttpClient;
use Symfony\Contracts\HttpClient\ResponseInterface;
use Psr\Log\AbstractLogger;
function printResponse(ResponseInterface $response): void
@dunglas
dunglas / example.php
Last active March 15, 2024 18:04
A GraphQL client using the Symfony HttpClient component
<?php
$query = <<<'GRAPHQL'
query GetUser($user: String!) {
user (login: $user) {
name
email
repositoriesContributedTo {
totalCount
}
@dunglas
dunglas / example.php
Created April 19, 2018 06:25
A minimalist GraphQL client for PHP
<?php
$query = <<<'GRAPHQL'
query GetUser($user: String!) {
user (login: $user) {
name
email
repositoriesContributedTo {
totalCount
}