Skip to content

Instantly share code, notes, and snippets.

Avatar

Kévin Dunglas dunglas

View GitHub Profile
@dunglas
dunglas / gist:4da2026f34bf7f18e1db955ef8a9b417
Last active Dec 18, 2020
Proposal: new public API for API Platform and the TypeScript library
View gist:4da2026f34bf7f18e1db955ef8a9b417
<?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 Dec 5, 2020
Working on API Platform during #SymfonyHackday
@dunglas
dunglas / uri-template.php
Created May 25, 2020
URI Template test in PHP
View uri-template.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
URI Template test in Ruby
View uri-template-test.rb
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
URI Template test in Java
View DemoApplication.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
URI Template test in C#
View Program.cs
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 Apr 20, 2020 — forked from CLAassistant/SAP_CLA
Kévin Dunglas Individual Contributor License Agreement
View Dunglas_CLA
### 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,
View test-push.php
#!/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 May 25, 2020
A GraphQL client using the Symfony HttpClient component
View example.php
<?php
$query = <<<'GRAPHQL'
query GetUser($user: String!) {
user (login: $user) {
name
email
repositoriesContributedTo {
totalCount
}
@dunglas
dunglas / example.php
Created Apr 19, 2018
A minimalist GraphQL client for PHP
View example.php
<?php
$query = <<<'GRAPHQL'
query GetUser($user: String!) {
user (login: $user) {
name
email
repositoriesContributedTo {
totalCount
}
You can’t perform that action at this time.