PHPackages                             sinevia/php-serverless - 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. sinevia/php-serverless

ActiveLibrary

sinevia/php-serverless
======================

PHP Serverless

v3.8.0(6y ago)3463PHP

Since May 31Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Sinevia/php-serverless)[ Packagist](https://packagist.org/packages/sinevia/php-serverless)[ RSS](/packages/sinevia-php-serverless/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (16)Versions (30)Used By (0)

PHP SERVERLESS FRAMEWORK
========================

[](#php-serverless-framework)

The first and fully functional PHP framework built exclusively for serverless. Support for [IBM Cloud Functions](https://www.ibm.com/uk-en/cloud/functions)

[![Build status](https://camo.githubusercontent.com/ab872cec837ed5fea3a55a4f8edf00afb9fb0f78a4e63ae453978e53a58c6f5e/68747470733a2f2f6170692e7472617669732d63692e636f6d2f53696e657669612f7068702d7365727665726c6573732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Sinevia/php-serverless)[![GitHub stars](https://camo.githubusercontent.com/647f629c36a14ae9d89b7f460e50337614bda3eb7b0038873eabff8ee39327b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f53696e657669612f7068702d7365727665726c6573732e7376673f7374796c653d736f6369616c266c6162656c3d53746172266d61784167653d32353932303030)](https://GitHub.com/Sinevia/php-serverless/stargazers/)[![HitCount](https://camo.githubusercontent.com/174b83234460353a6dc7ba702c6ed8bc962492182649349fde67c176d0e50307/687474703a2f2f686974732e6477796c2e696f2f53696e657669612f6261646765732e737667)](http://hits.dwyl.io/Sinevia/badges)

FEATURES
--------

[](#features)

- Easy to learn and start. All required is in this README file.
- Fully automated and extendable via RoboFile ([learn more](https://robo.li/)).
- Powerful and super fast router ([learn more](https://github.com/mrjgreen/phroute)).
- Lean database library ([learn more](https://github.com/Sinevia/php-library-sqldb)). Eloquent optional.
- Lean template engine ([learn more](https://github.com/Sinevia/php-library-template)). Blade optional.
- Lean testing framework ([learn more](https://github.com/BafS/Testify.php)). PhpUnit optional.
- Uses tested serverless deployment framework ([learn more](https://serverless.com/))

INSTALLATION
------------

[](#installation)

1. Step 1

```
composer create-project --prefer-dist sinevia/php-serverless .

```

2. Step 2

```
vendor/bin/robo init

```

AFTER INSTALLATION
------------------

[](#after-installation)

- Delete the phpunit.xml file, if you are not going to use PHPUnit for testing
- Change the settings in /app/config (serverless function name, etc)
- Change the settings in /env.php (not required usually)

WORKFLOW
--------

[](#workflow)

Four environments are specified and available out of the box - local, testing, staging, live.

1. Local. All development is done on local - (local)
2. Testing. Automatic tests are run in testing - (testing)
3. Staging. For user and manual testing depoy to staging - (staging)
4. Live. For real live usage deploy to live - (live)

DEVELOPMENT
-----------

[](#development)

To start working on the project run the built in PHP server:

```
php -S localhost:32222

```

or using the helper function

```
vendor/bin/robo serve

```

Then open in browser:

or using the helper function

```
vendor/bin/robo open local

```

DATABASE
--------

[](#database)

To run migrations for each environment:

```
vendor/bin/robo migrate local

```

```
vendor/bin/robo migrate staging

```

```
vendor/bin/robo migrate live

```

DEPLOYMENT
----------

[](#deployment)

The deployment will run your tests, and will continue only if your tests are successful

To deploy to your staging function

```
vendor/bin/robo deploy staging

```

To deploy to your live function

```
vendor/bin/robo deploy live

```

HELPER FUNCTIONS
----------------

[](#helper-functions)

A RoboFile exists with automated functionality.

- Run database migrations on local

```
vendor/bin/robo migrate local

```

- Run database migrations on staging

```
vendor/bin/robo migrate local

```

- Run database migrations on live

```
vendor/bin/robo migrate live

```

- Serve the site for development

```
vendor/bin/robo serve

```

- Open local/dev url from terminal

```
vendor/bin/robo open local

```

- Open staging url from terminal

```
vendor/bin/robo open staging

```

- Open live url from terminal

```
vendor/bin/robo open live

```

- Deploy to staging

```
vendor/bin/robo deploy staging

```

- Deploy to live

```
vendor/bin/robo deploy live

```

TESTING
-------

[](#testing)

Two testing frameworks supported out of the box:

1. Testify.php - very lean and straghtforward to work with (preferred, and preinstaled)
2. PHPUnit - more mature, but heavy weight with many dependencies

To decide which modify the setting in the RoboFile.

### Testing with Testify.php

[](#testing-with-testifyphp)

Testify is a small PHP testing library with no extenal dependencies:

Place your tests in /tests/test.php

To run the tests

```
php tests/test.php

```

or

```
vendor/bin/robo test

```

### Testing with PHPUnit

[](#testing-with-phpunit)

PHPUnit is a huge PHP testing library. Beware it will come with lots of composer dependencies:

To install the framework with all the dependencies

```
composer require --dev phpunit/phpunit

```

Place your settigs in /phpunit.xml. Place your tests in /tests

To run the tests

```
vendor/bin/phpunit

```

or

```
vendor/bin/robo test

```

SERVING STATIC FILES
--------------------

[](#serving-static-files)

Multiple options

Local CSS and JavaScript files are best to be served minified inline. Helper functions are added

```

```

Small images (i.e. favicon) serve inline as data.

```
