Skip to content

Instantly share code, notes, and snippets.

View reyostallenberg's full-sized avatar

Reyo Stallenberg reyostallenberg

  • Rotterdam, The Netherlands
View GitHub Profile
@alexander-schranz
alexander-schranz / config.json
Created January 18, 2019 16:04
Composer config.json to always install source for specific packages
{
"config": {
"preferred-install": {
"sulu/*": "source",
"handcraftedinthealps/*": "source",
"massive/*": "source"
}
}
}
@florentdestremau
florentdestremau / NewPasswordType.php
Last active March 10, 2023 13:17
A simple User authentication setup to copy & paste into your Symfony 3.4 install
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
@alexander-schranz
alexander-schranz / AppExtension.php
Created July 24, 2018 09:57
Automatic versioning update on npm run build
<?php
namespace AppBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
@Xymanek
Xymanek / DataConnectionWrapper.php
Created August 23, 2017 08:17
Symfony multi-tenant database
<?php
namespace AppBundle\Doctrine;
use AppBundle\Entity\Organisation;
use Doctrine\DBAL\Connection;
use Acme\Common\DatabaseNameResolver;
class DataConnectionWrapper extends Connection
{
/**
@magnuspalmer
magnuspalmer / rancher-setup-windows.md
Created September 22, 2016 09:33
Rancher scratchpad

Setup Rancher on windows for fun and work (and probably Linux as well)

Create a network - ranchernet

docker network create --subnet 173.18.0.0/16 ranchernet

Start the server, use the ranchernet and assign static IP

docker run -d --restart=always --net ranchernet --ip=173.18.0.2 -p 8080:8080 rancher/server

Through the Rancher UI, get the command, but add it also to the rancher net and give static ip

docker run -e CATTLE_AGENT_IP="173.18.0.3" --net ranchernet --ip 173.18.0.3 -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 http://173.18.0.2:8080/v1/scripts/

@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

master:
image: rancher/server
container_name: master
volumes_from:
- mysql
ports:
- "8080:8080"
links:
- mysql
environment:
@janvennemann
janvennemann / DisconnectedMetadataFactory.php
Last active February 20, 2018 09:31
Changes for DoctrineBundle PSR-4 support
<?php
class DisconnectedMetadataFactory
{
//...
/**
* Get a base path for a class
*
* @param string $name class name
* @param string $namespace class namespace
@tjamps
tjamps / README.md
Last active February 29, 2024 14:57
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 :

@danvbe
danvbe / 1-Explanations.md
Last active April 21, 2023 15:39
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.