Skip to content

Instantly share code, notes, and snippets.

View osteel's full-sized avatar
🙂

Yannick Chenot osteel

🙂
View GitHub Profile
openapi: 3.1.0
info:
title: OpenAPI HttpFoundation Testing Laravel Example
version: 1.0.0
servers:
- url: http://localhost:8000/api
paths:
<?php
namespace Tests\Feature;
use Osteel\OpenApi\Testing\ValidatorBuilder;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
@osteel
osteel / posts.php
Created January 10, 2021 15:53
Example PHP script to parse a blog's RSS feed
<?php
// Load Composer's autoload
require_once __DIR__ . '/vendor/autoload.php';
// Load the RSS feed
$feed = Feed::loadRss('https://tech.osteel.me/feeds/rss.xml')->toArray();
// Generate the list of blog posts
$posts = '';
@osteel
osteel / posts.yml
Created January 10, 2021 16:18
Example GitHub Action to instal Composer dependencies and run a PHP script
name: Update blog posts
on:
push:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
build:
<?php
namespace Osteel\PhpCliDemo\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class Play extends Command
$term1 = rand(1, 10);
$term2 = rand(1, 10);
$result = $term1 + $term2;
$io = new SymfonyStyle($input, $output);
$answer = (int) $io->ask(sprintf('What is %s + %s?', $term1, $term2));
if ($answer === $result) {
$io->success('Well done!');
@osteel
osteel / demo
Created February 6, 2022 12:46
#!/usr/bin/env php
<?php
require __DIR__.'/../vendor/autoload.php';
use Symfony\Component\Console\Application;
$application = new Application();
// ... register commands
@osteel
osteel / demo
Created February 6, 2022 12:47
#!/usr/bin/env php
<?php
require __DIR__.'/../vendor/autoload.php';
use Osteel\PhpCliDemo\Commands\Play;
use Symfony\Component\Console\Application;
$application = new Application();
<?php
namespace Osteel\PhpCliDemo\Services;
use Symfony\Component\Console\Style\SymfonyStyle;
class InputOutput extends SymfonyStyle
{
/**
* Ask a question and return the answer.
<?php
namespace Osteel\PhpCliDemo\Commands;
use Osteel\PhpCliDemo\Services\InputOutput;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Play extends Command