PHPackages                             virge/api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. virge/api

ActiveLibrary

virge/api
=========

v2.0.1(8y ago)022112PHP

Since Mar 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/siosphere/virge-api)[ Packagist](https://packagist.org/packages/virge/api)[ RSS](/packages/virge-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (1)Versions (12)Used By (2)

Virge::Api
==========

[](#virgeapi)

Virge::Api allows the simple creation of API endpoints.

Virge::Api allows defining get/post/put/delete methods, as well as chaining API authentication methods by defining custom verifiers.

Getting Started
---------------

[](#getting-started)

To use Virge::Api you should start with a default Virge::Project

```
composer create-project virge/project ./my-project

```

This will create an empty Virge::Reactor, and create the skeleton required to setup the Api.

The entire directory needs to exist on your webserver, but the entry directory should be the ./public directory, this can be symlinked:

```
# assuming the project exists in /var/www/my-project
ln -s /var/www/my-project/public /var/www/html

```

This can also be done using docker:

```
docker run -d -v $PWD:/var/www/my-project -p 3000:80 siosphere/php7

```

Once the container is up, you'll need to run the symlink command like above

Virge::Project also requires rewrites, for apache you can set that up by creating myproject.conf in /etc/httpd/conf.d/

```

    Options FollowSymLinks
    AllowOverride All

```

Restarting the docker container or apache will then allow you to visit localhost:3000 in your browser. You will get a 500 error, a blank white page, or a 404 page depending on configuration. This is because there is no routing or routes setup.

### Hello Api

[](#hello-api)

We need to include Virge::Api as a capsule, and add the package to our project:

```
composer require virge/api

```

To create our first API route, we need to create our First Capsule. A Capsule is registered with the Reactor and will automatically load configuration files for us, loading services, controllers, and api definition files.

Under the src directory we can create a MyProject directory We will need to create MyProjectCapsule.php under this directory:

```
