This is a development version of the new talis-php version. It is not yet intended for general use. This early version pulls existing individual client libraries into one single library with minimal changes.
Before releasing for general usage there will be major changes to the API. The library will move
away from the use of internal Talis project names like Persona, Critic, Babel and Echo etc.
Instead it will use more externally relevant names like ListReviews
and Files
.
The API will also move to a more domain driven design rather than the service driven design
of the individual libraries
See issue: #2 and Milestone: https://github.com/talis/talis-php/milestone/1
A Dockerfile is provided to make it easy to get a local development environment up and running to develop and test changes. Follow these steps:
Clone the repo locally:
git clone https://github.com/talis/talis-php.git
cd talis-php
Integration tests run locally will make requests to Persona at http://persona.talis.local
.
Before you begin, ensure you have established DEVELOPMENT_WORK_DIR
and the infra
repository, as per the shared project instructions.
Manually run persona locally:
./docker-compose-dev.sh persona-server
If you are running Persona using the instructions above you can skip this step. If you want to create you own OAuth client, read on.
To run talis-php tests, the OAuth client must have su
scope. It's not possible to create a client with su
scope via the API.
-
Create a client:
curl -H "Authorization: Bearer $(persona-token)" -d "{\"scope\":[\"su@test\"]}" http://persona.talis.local/clients
This will return a client, e.g.:
{"client_id":"BXLmKR79","client_secret":"zdlbESLEFGvxBw8k"}
-
Connect to the mongo database the local persona is using and manually give the client
su
scope.cd $DEVELOPMENT_WORK_DIR/infra docker compose exec mongo32 mongo # in mongo shell use persona db.oauth_clients.updateOne({ client_id: "<client_id>" }, { $addToSet: { scope: "su" } }) db.oauth_clients.find({ client_id: "<client_id>" }).pretty()
-
Create an
.env
file with required environment variables:cd $DEVELOPMENT_WORK_DIR/talis-php cat > .env <<EOL PERSONA_TEST_HOST=http://persona.talis.local PERSONA_TEST_OAUTH_CLIENT=<client_id> PERSONA_TEST_OAUTH_SECRET=<client_secret> EOL
Remember to replace
PERSONA_OAUTH_CLIENT
andPERSONA_OAUTH_SECRET
with values ofclient_id
andclient_secret
respectively.
Run the following command which should build the Docker image (if it's missing) and will download the required libraries:
docker compose run --rm init
If you want to rebuild the Docker image at any point, run:
docker compose build
Available test commands:
docker compose run --rm lint
docker compose run --rm test
docker compose run --rm unittest
docker compose run --rm integrationtest
To create a docker container where you can run commands directly, for example to run individual tests:
docker compose run --rm local-dev
You can then run ant commands individually or run individual tests:
/vendor/bin/phpunit --filter testCreateUserThenPatchOAuthClientAddScope test/integration/
Additionally we provide tools to run static analysis on the code base:
docker compose run --rm code-check
docker compose run --rm analyse