After many hours to struggling with CORS while trying to get Vue 2 to talk to my Symfony API, I finally pulled this working distribution together.
It is simply the the minimum required packages for a Symfony API and it works.
It includes
- nelmio/NelmioCorsBundle
- lexik/LexikJWTAuthenticationBundle
- FOSUserBundle
- DoctrineMigrationsBundle
I have purposefully not added FOSRestBundle or any serializer bundle as the the built in Symfony Response and Serializer tools can do this, leaving the package as clean as possible.
Enjoy.
Make sure to checkout the Master Branch
$ mkdir -p var/jwt # For Symfony3+, no need of the -p option
$ openssl genrsa -out var/jwt/private.pem -aes256 4096
$ openssl rsa -pubout -in var/jwt/private.pem -out var/jwt/public.pem
Add your the password you used to generate to keys to your parameters file
jwt_private_key_path: '%kernel.root_dir%/../var/jwt/private.pem' # ssh private key path
jwt_public_key_path: '%kernel.root_dir%/../var/jwt/public.pem' # ssh public key path
jwt_key_pass_phrase: 'Your Password' # ssh key pass phrase
jwt_token_ttl: 3600
Welcome to the Symfony Standard Edition - a fully-functional Symfony application that you can use as the skeleton for your new applications.
For details on how to download and get started with Symfony, see the Installation chapter of the Symfony Documentation.
The Symfony Standard Edition is configured with the following defaults:
-
An AppBundle you can use to start coding;
-
Twig as the only configured template engine;
-
Doctrine ORM/DBAL;
-
Swiftmailer;
-
Annotations enabled for everything.
It comes pre-configured with the following bundles:
-
FrameworkBundle - The core Symfony framework bundle
-
SensioFrameworkExtraBundle - Adds several enhancements, including template and routing annotation capability
-
DoctrineBundle - Adds support for the Doctrine ORM
-
TwigBundle - Adds support for the Twig templating engine
-
SecurityBundle - Adds security by integrating Symfony's security component
-
SwiftmailerBundle - Adds support for Swiftmailer, a library for sending emails
-
MonologBundle - Adds support for Monolog, a logging library
-
WebProfilerBundle (in dev/test env) - Adds profiling functionality and the web debug toolbar
-
SensioDistributionBundle (in dev/test env) - Adds functionality for configuring and working with Symfony distributions
-
SensioGeneratorBundle (in dev env) - Adds code generation capabilities
-
WebServerBundle (in dev env) - Adds commands for running applications using the PHP built-in web server
-
DebugBundle (in dev/test env) - Adds Debug and VarDumper component integration
All libraries and bundles included in the Symfony Standard Edition are released under the MIT or BSD license.
Enjoy!