Skip to content

Instantly share code, notes, and snippets.

@Mulkave
Last active September 15, 2016 13:40
Show Gist options
  • Save Mulkave/8374c323a1342d640a7617e3b4478674 to your computer and use it in GitHub Desktop.
Save Mulkave/8374c323a1342d640a7617e3b4478674 to your computer and use it in GitHub Desktop.

Trellis • My Service

This service fetches ghosts and throws them at every client requesting it, in the hope of being haunted.

Namespace: Trellis\MyService

Requirements

  • PHP >= 5.6.4
  • OpenSSL PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • 666 Spirit Lifter Extension
  • RabbitMQ

Installation

  • git clone this repo
  • cd service directory
  • composer install --no-dev --prefer-dist

Configuration

  • Create a .env file at the root of the project by copying .env.example
  • Update .env with the corresponding values

Usage

There are two ways to use this package:

HTTP

GET /ghosts

Params
  • limit : int (default = 10)
  • traning_level : string (default = none)
  • order_by : string (default = name, values = [id, name, occupation])
Response
{
  "id": "hjkags768itaugsdhjf",
  "name": "The Name",
  "occupation": "airbender",
  "created_at": "10-11-2016"
}
Error Response
{
  "error": {
    "code": "666",
    "message": "die"
  }
}
Special Case Response
{
  "error": {
    "code": "7373",
    "message": "You shouldn't have done this"
  }
}

Messaging Queue

Consuming

Queue: a-queue-name
  • Type: fanout
  • Data
{
  "key": "value",
  "another": "one",
  "and": "more",
  "like": "the previous one"
}

Producing

Queue: other-queue
  • Type: default
  • Data
{
  "something": "happened",
  "and": "it was",
  "successfully": "performed"
}

Development

To setup this project for development:

  • Install the dependencies with dev packages
composer install
  • Run a database using docker run -d -p 7474:7474 neo4j
  • Configure the test environment in the tests/config.php file
'database' => [
  'neo4j' => [
    'host' => 'the-dev-host',
    'port' => 7474
  ],
]
  • Testing uses the PHPUnit tool so run them using phpunit

License

(c) Vinelab 2016 dev@vinelab.com

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment