Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Sample implementation of an OAuth2 client for Maniaplanet into Symfony

License

Notifications You must be signed in to change notification settings

askuri/maniaplanet-oauth-symfony

Repository files navigation

About this

This is to help Maniaplanet coders to setup a working OAuth2 client to communicate with the Maniaplanet v4 webservices by using Symfony 4.1. Yet, it is simply a fresh symfony install with "login with maniaplanet" functionality and a few sample sites.

Getting started

Things you should have some basic knowledge about:

  • Composer. We assume you have installed it globally
  • Symfony. Learning by doing is possible, though it's a good idea to at least read through their "Getting Started" section in the docs
  • Basics of OAuth2

Also these commands were tested on Linux. On Windows you may adjust the commands. Check the documentation related to the used commands.

If you're using Git, you can run this, where you want to run your website:

$ git clone git@github.com:askuri/maniaplanet-oauth-symfony.git

Otherwise you can download a zip here: https://github.com/askuri/maniaplanet-oauth-symfony/archive/master.zip. Extract it.

Change into the directory that was just created by cloning/unpacking

$ cd maniaplanet-oauth-symfony

And tell composer to get the libraries (vendor folder) for you

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 99 installs, 0 updates, 0 removals
  - Installing ocramius/package-versions (1.3.0): Loading from cache
  - [...]
  - Installing symfony/web-server-bundle (v4.1.0): Loading from cache
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [OK]
Executing script assets:install --symlink --relative public [OK]

That's it already. Now you're ready to start the development server of Symfony:

bin/console server:run

Keep the terminal / commandline open. You'll find the sample on http://localhost:8000/

Going on

While running composer install, the file .env (may be hidden on your system by default) has been created from .env.dist. It's the environment configuration which needs to be changed on all computers. You have so set your credentials for database and OAuth there.

Below is a list of files, which are relevant to the sample (others are autogenerated by Symfony and don't require further attention at this point). Change them to your needs.

Here is a list of links which may be helpful to you:

Description of files

Mandatory files

It's unlikely you have to make big changes here. You may change them later to add functionality.

  • src/Entity/ManiaplanetUser.php: object representing the user (containing login, nickname ...)
  • src/Repository/ManiaplanetUserRepository.php: dummy respository created alongside the ManiaplanetUser entity by bin/console make:entity
  • src/Security/OAuth2/*: contains the basic functionality of the client

App files

List of files which are used to demonstrate the usage. Adjust them to your needs.

  • src/Controller/*: simple page controllers
  • src/Controller/ManiaplanetController.php: is special because it is the start and endpoint of the authentication process
  • templates/*

Config files

List of configs I have edited in order to get the app running.

  • config/packages/knpu_oauth_client.yaml
  • config/packages/security.yaml
  • config/routes.yaml
  • config/services.yaml: adding a service tag for the provider (last line)
  • .env: create this file from .env.dist. Insert DB connection and OAuth credentials

About

Sample implementation of an OAuth2 client for Maniaplanet into Symfony

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published