Download the PHP package brewinteractive/fakend without Composer

On this page you can find all versions of the php package brewinteractive/fakend. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fakend

Fakend


Fakend provides mock api from json schemas. It has been written in PHP and sits on a couple of great php libs such as thephpleague's fractal[1], fzaninotto's faker[2] and memio's generator lib[3].

  1. https://github.com/thephpleague/fractal
  2. https://github.com/fzaninotto/Faker
  3. https://github.com/memio/memio

It had been designed to provide mock API specifically for ember-data but this update changes model notation from ember-data model to global JSON notation to provide more flexible mock API backend for all frontend apps.

How to get

Quick Look:

Fakend Install Gif

How to define models for Fakend

You need to generate model files first. You have to place model files to /api/Models/ directory then you need to add class properties as shown:

post.js

To resolve belongsTo:

author.js

To resolve hasMany:

comment.js

Parameters

Option Parameters Description
id - return id for record
title length[integer] title formatted string
description length[integer], html[boolean] long text formatted string
numberBetween min[integer], max[integer] provides a number in given range
date from[string], e.g: -4 year, to[string] e.g +1 day returns a iso_8601 date in given range
boolean  - returns boolean value in 50% change
random  vales[array] return selected value from given array
url - returns random rul
json - -
imageUrl required[boolean], type['avatar or default'] returns a random image url from lorempixel.com
mimeType - returns mime type for files
firstname - returns real name
lastName - returns real lastname
html - returns html formatted text

How to generate model class

First, you "parser" executable symbolic link has been generated during install progress in first step. When you navigate to root directory folder then you can execute following command to generate schema files.

If you do not provide modelName, fakend will generate php schema classes for all models. modelName is single model name to generate/update single model file.

This will generate /api/Schema/Post.php and will consist of model's attributes.

How to use

Fakend ships with basic silex app at api/ directory and each Fakend provides CRUD metods(GET/POST/PUT/DELETE) endpoint will be generated and placed at this file. New endpoints will be append end of this file.

If you want to optimize or change methods you can use followings. In index.php:

This adds fakend base class.

Fakend uses League's Fractal library for serializations. You can use following default fractal serializers or you can use your own custom serializer class to format your response data.

A basic custom .NET web api serializer has been added to project as an example.

Then you need to initialize related model class and need to pass serializer.

From $post variable, you can call:

Method Description
setMeta(array) to set metadata.
get(id) to get an record for provided id.
getMany(limit) to get number of records from api.
setBelongsTo(belongsToObject) to set same belongsTo item for all requested records.
setBelongsToByName(name, belongsToObject) to set belongsto property by name.
setParentObject(parent) to set same parent object for all recursive models.

Docker

We provide a docker container(PHP & NGINX) at root directory. You just need to build & up.

Silex example

You can find sample outputs for this example in samples/ folder.


All versions of fakend with dependencies

PHP Build Version
Package Version
Requires php Version ^5.3.3|^7.0
league/fractal Version ~0.17.0
fzaninotto/faker Version *
danielstjules/stringy Version ~3.1.0
memio/memio Version ~2.0
symfony/console Version *
silex/silex Version ~2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package brewinteractive/fakend contains the following files

Loading the files please wait ....