ow-php-todo-backend

A Todo-Backend implementation in OpenWhisk PHP

MIT License

Stars
7
Committers
1

Todo-Backend for OpenWhisk PHP

This is an OpenWhisk API written in PHP that implements Todo-Backend.

It uses Pimple for dependency injection and Fractal for the presentation layer. The data is stored in (PostgreSQL](https://www.postgresql.org) hosted by ElephantSQL via PDO.

Set up

  1. Ensure you have an an IBM Cloud account to deploy to their OpenWhisk service (called Functions)

  2. Set up the bx command line tool and set your workspace.

  3. Set up a (free) ElephantSQL service in your IBM Cloud and bind the credentials to an OpenWhisk package called "todo-backend":

    $ bx service create elephantsql turtle bookshelf-db
    $ bx service key-create bookshelf-db key1
    $ bx wsk package create todo-backend
    $ bx wsk service bind elephantsql --instance bookshelf-db todo-backend
    
  4. Install the Serverless Framework

    $ npm install --global serverless serverless-openwhisk
    
  5. Clone this repo

  6. Run the package managers:

    $ npm install
    $ composer install
    
  7. Deploy the API using the sls command:

    $ sls deploy
    

    Take a note of the URL to the "list-todos" endpoint in the "endpoints (api-gw)" section as we'll need it later.

  8. Create the database table

    $ sls invoke -f create-schema
    

Your API is now up and running.

Running the test

Visit the TodoBacked test suite and enter the list-todos endpoint from the endpoints (api-gw) section when you ran sls deploy. You can run sls info to view it again.

Press the Run tests button.