Link Search Menu Expand Document

Standalone PHP Solid Server

Project stage: Development License Latest Version Maintained

PDS Interop standard-readme compliant keep-a-changelog compliant

Standalone Solid Server written in PHP by PDS Interop

Table of Contents

Background

The Solid specifications defines what makes a “Solid Server”. Parts of those specifications are still likely to change, but at the time of this writing, they define:

  • Authentication
  • Authorization (and access control)
  • Content representation
  • Identity
  • Profiles
  • Resource (reading and writing) API
  • Social Web App Protocols (Notifications, Friends Lists, Followers and Following)

Installation

To install the project, clone it from GitHub and install the PHP dependencies using Composer:

git clone git://github.com/pdsinterop/php-solid-server.git \
    && cd php-solid-server \
    && composer install --no-dev --prefer-dist

At this point, the application is ready to run.

Usage

The PHP Solid server can be run in several different ways.

The application can be run with a Docker image of your choice or on a local environment, using Apache, NginX, or PHP’s internal HTTP server. The latter is only advised in development.

For security reasons, the server expects to run on HTTPS (also known as HTTP+TLS).

To run insecure, for instance when the application is run behind a proxy or in a PHP-FPM (or similar) setup, set the environment variable PROXY_MODE. This will allow the application to accept HTTP requests.

Docker images

When running with your own Docker image, make sure to mount the project folder to wherever the image expects it to be, e.g. /app or /var/www.

For instance:

export PORT=8080 &&        \
docker run                 \
   --env "PORT=${PORT}"    \
   --expose "${PORT}"      \
   --network host          \
   --rm                    \
   --volume "$PWD:/app"    \
   -it                     \
   php:7.3                 \
   php --docroot /app/web/ --server "localhost:${PORT}" /app/web/index.php

Or on Mac:

export PORT=8080 &&        \
docker run                 \
   --env "PORT=${PORT}"    \
   --expose "${PORT}"      \
   -p "${PORT}:${PORT}"    \
   --rm                    \
   --volume "$PWD:/app"    \
   -it                     \
   php:7.3                 \
   php --docroot /app/web/ --server "localhost:${PORT}" /app/web/index.php

Local environment

How to run this application in an Apache, NginX, or other popular HTTP servers falls outside the scope of this project.

For development purposes, the internal PHP HTTP server is explained below.

Built-in PHP HTTP server

For development purposes a Composer serve-dev command has been provided. This will run the application using PHP internal HTTP server.

To use it, run composer serve-dev in the project root.

!!! FOR SECURITY REASONS, DO NOT USE THIS METHOD IN PRODUCTION !!!

By default, the application is hosted on localhost port 8080. So if you visit http://localhost:8080/ with your browser, you should see “Hello, World!”.

Both the HOST and PORT can be configured before running the command by setting them in the environment, for instance:

HOST='solid.local' PORT=1234 composer serve-dev

This command can also be run through a docker container, for instance:

export PORT=8080 &&     \
docker run              \
   --env "PORT=${PORT}" \
   --expose "${PORT}"   \
   --network host       \
   --rm                 \
   --volume "$PWD:/app" \
   -it                  \
   composer:latest      \
   serve

Running solid/webid-provider-tests

Due to https://github.com/pdsinterop/php-solid-server/issues/8 you should run, in one terminal window:

HOST=127.0.0.1 composer serve-dev

and in another you run the webid-provider-test as:

SERVER_ROOT=http://localhost:8080 ./node_modules/.bin/jest test/surface/fetch-openid-config.test.ts

The current dev branch of php-solid-server should pass roughly 7 out of 17 tests.

Available Features

Based on the specifications, the features listed below should be available.

The checkboxes show which features are, and which ones are not.

The underlying functionality for these features is provided by:

  1. User
    • Authentication [auth] (since v0.3)
    • Identity (since v0.2)
    • Profiles (since v0.2)
  2. Data storage
    • Content representation [rdf] (since v0.4)
    • Resource API
      • HTTP REST API [crud] (since v0.4)
      • Websocket API [p/s] (since v0.6)
  3. Web Acces Control List
    • Authorization (and Access Control) [crud] (since v0.6)
  4. Social web apps
    • Calendar
    • Contacts
    • Friends Lists (Followers, Following)
    • Notifications

Development

The easiest way to develop this project is by running the environment provided by the docker-compose.yml file. This can be done by running docker-compose up.

This will start the application and a pubsub server in separate docker containers.

Project structure

This project is structured as follows:

  .
  ├── bin/          <- CLI scripts
  ├── config/       <- Empty directory where server configuration is generated
  ├── docs/         <- Documentation
  ├── src/          <- Source code
  ├── tests/        <- Test fixtures, Integration- and unit-tests
  ├── vendor/       <- Third-party and vendor code
  ├── web/          <- Web content
  ├── composer.json <- PHP package and dependency configuration
  └── README.md     <- You are now here

Testing

The PHPUnit version to be used is the one installed as a dev- dependency via composer. It can be run using composer test or by calling it directly:

$ ./bin/phpunit

Contributing

Questions or feedback can be given by opening an issue on GitHub.

All PDS Interop projects are open source and community-friendly. Any contribution is welcome! For more details read the contribution guidelines.

All PDS Interop projects adhere to the Code Manifesto as its code-of-conduct. Contributors are expected to abide by its terms.

There is a list of all contributors on GitHub.

For a list of changes see the CHANGELOG or the GitHub releases page.

License

All code created by PDS Interop is licensed under the MIT License.


Copyright © 2020-2021 PDS Interop. Distributed under a MIT license.