Download the PHP package neighborhoods/prefab without Composer

On this page you can find all versions of the php package neighborhoods/prefab. 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 prefab

Prefab

A code generation tool. Takes the busywork out of building strongly-typed, patterned HTTP applications.

Table of Contents

Getting Started

Installation

Prefab can be installed using Composer:

composer require neighborhoods/prefab

Running Prefab

Prefab Fitness

To see working examples on how you can use Prefab, check out the Prefab Fitness repository for examples with fully self-contained environments that you can run locally.

Prerequisites

PSR-4 Namespace Definition

Prefab assumes users have defined a psr-4 namespace under the autoload key in their composer.json file. Namespaces MUST be defined as {VENDOR}\{PRODUCT_NAME}. See the composer docs for more information. Prefab will write generated files under the fab/ directory in your project root. You should configure your autoloader to first look in src/, then in fab/. This will allow you to override generated files by placing updated copies of classes in the equivalent src/ location.

Example:

Environment Variables

Prefab expects the following environment variables to be defined.

Key Description
SITE_ENVIRONMENT The environment the application is running in. Should be one of Local, Development, or Production
DATABASE_ADAPTER The database driver to use. See the Doctrine DBAL docs for possible values
DATABASE_HOST The database host to use in the PDO connection
DATABASE_USERNAME The database username to use in the PDO connection
DATABASE_PASSWORD The database password to use in the PDO connection
DATABASE_NAME The database name to use in the PDO connection
DATABASE_PORT The database port to use in the PDO connection

Project Structure

Prefab requires that all Prefab definition files be in a versioned directory under src/. For example, src/V1/Actor.prefab.definition.yml is valid while src/Actor.prefab.definition.yml is not.

Materialized Views

Prefab puts an extremely high focus on performance. One of the ways Prefab achieves fast response times is by ensuring that all HTTP requests result in a single database query on an index, made possible through the use of materialized views. Prefab uses search criteria to interact with its database, which doesn't support table joins. That means all data for a given request MUST live in the same table.

Note: Since search criteria allows you to select which data you would like to return, a single materialized view with a superset of all data returned by your HTTP endpoints can be used.

Prefab Definition File Specification

The purpose of this document is to define the components needed to generate an HTTP endpoint for an actor from a .prefab.definition.yml file

The file MUST be named {ACTORNAME}.prefab.definition.yml and saved under src/. They should be stored in the same nested directory structure as you would like the machinery to be generated under fab/.

Example Prefab Definition File:

Filename: User.prefab.definition.yml

Search Criteria

Search Criteria is a data mining query language (DMQL) utilized by Prefab applications to provide a flexible API that enables HTTP clients to define how they want to ask for data rather than services explicitly implementing each use case. Search Criteria consists of filters along with optional sort order and pagination instructions.

Filters

Search Criteria filters are used to define the WHERE clause of a database query. Filters should be included as an array under the searchCriteria[filters] key. Each filter consists of the following:

Query Parameter Key: searchCriteria[filters]

Key Data Type Description
field string The database column the filter applies to
condition string The condition to query by. See below for a full list of conditions
values array The values to include in a query. If a condition is used that only applies to a single value (eg. =) any values after the first will be ignored
glue string The condition to use when grouping filters together. Can be either and or or

Conditions

Key Condition Description
eq = Will match values that = values[0]
neq <> Will match values that != values[0]
in IN Will match values that are in values
nin NOT IN Will match values that are not in values
lt < Will match values that are less than values[0]
lte <= Will match values that are less than or equal to values[0]
gt > Will match values that are greater than values[0]
gte >= Will match values that are greater than or equal to values[0]
like LIKE Will match values that are like values[0]
nlike NOT LIKE Will match values that are not like values[0]
is_null IS NULL Will match values where field is null
is_not_null IS NOT NULL Will match values where field is not null
st_contains ST_Contains(field, st_geomfromtext(value)) Will match values where field contains values[0]
st_dwithin ST_DWithin(field, center, radius) Will match values where field is within point values['center'] with a radius of values['radius']
st_within ST_Within(field, st_buffer(st_geomfromtext(center), radius)) Will match values where field is within point values['center'] with a radius of values['radius']
contains field @> ARRAY[values] Will match values where json field contains all values
overlaps field && ARRAY[values] Will match values where json field contains any values
jsonb_key_exist jsonb_exists(field, value) Will match where values[0] exists as a jsonb key in field

Sort Order

A sort order is used to define the order in which data should be returned. It consists of an array with field and a direction.

Query Parameter Key: searchCriteria[sortOrder]

Key Description
field Database column the sort applies to
direction The order to be applied to the sort. Can be either asc or desc

Pagination

A page size can be defined in order to limit the number of results returned by a query. Set a page size by providing an integer under the key searchCriteria[pageSize]. You can retrieve additional pages of data by supplying a current page. Set the current page by providing an integer under the key searchCriteria[currentPage].

Supporting Actor Groups

Prefab supports generating different subsets of supporting actors to support various use cases. For information on how to specify a supporting actor group, see the Prefab definition file specification. The following supporting actor groups are available:

Subset Container Buildable Directories

As Symfony containers get bigger, the response times for HTTP requests increase. To prevent slow response times, Prefab supports user-defined subset container building. Prefab users can define what should be included in the Symfony container for each route, so only the necessary actors are initialized. This buildable directory file is optional and Prefab will build the entirety of src/ and fab/ by default if the file is not found. If the file is present, then all routes MUST have a corresponding key with directories to be built.

top_level_key - should be the URI. If a key with the first two parts of the URI is not found, Prefab will then check for a key with only the first part.

buildable_directories - Represents the directories of HTTP actors you would like to include for a given request. Each buildable directory will include the corresponding path under both src/ and fab/. Since the buildable_directories represents paths, forward slashes (/) should be used as a separator.

welcome_baskets - These are the namespaces of the HTTP machinery that Prefab generates that should be included in a request. Since welcome_baskets represent namespaces, backslashes (\) should be used as a separator.

appended_paths - These are any additional paths that you want included in your container that are not under fab/ or src/. Paths are relative to the root of your project. Since appended_path represents paths, forward slashes (/) should be used as a separator.

Example

By default, Symfony containers are built on the first HTTP request. Since this can add a significant amount of time to the first request, it is recommended that you prebuild your containers before serving production traffic. This can be accomplished by adding the following script to your bin/ directory and including it as a post-update-cmd and/or post-install-cmd script in your composer.json file after vendor/bin/prefab.

Semantic Versioning

Since Prefab is a code generation tool that allows users to override specific files and behaviors as needed, Prefab can't make a guarantee a minor version upgrade will work with your overriden files. Prefab does guarantee that all minor version upgrades of a purely Prefabbed project (no overriden files) will not have any breaking changes. If you do override any files, it's important that you test your project to verify those files still work as expected with the new version of Prefab.

Debug Mode

Debug mode can be enabled by setting the environment variable DEBUG_MODE=true. Enabling debug mode will output additional details about exceptions and errors thrown during HTTP requests. If there is an error during container building (eg. A missing Symfony service file), you will have the additional visibility provided by debug mode. Debug mode will try to send the error to STDERR and also it will try to log the error in /Logs/HTTP.log


All versions of prefab with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3
jsoumelidis/zend-sf-di-config Version ^0.3
doctrine/dbal Version 2.7 - 2.12
symfony/config Version ^4.4
symfony/console Version ^4.4
symfony/dependency-injection Version ^4.4
symfony/expression-language Version ^4.4
symfony/filesystem Version ^4.4
symfony/finder Version ^4.4
symfony/yaml Version ^4.4
laminas/laminas-code Version ^3.3
laminas/laminas-component-installer Version ^2.1.1
laminas/laminas-config-aggregator Version ^1.0
laminas/laminas-diactoros Version ^1.7.1
mezzio/mezzio Version ^3.0.1
mezzio/mezzio-fastroute Version ^3.0
mezzio/mezzio-helpers Version ^5.0
laminas/laminas-http Version ^2.14.2
mezzio/mezzio-problem-details Version ^1.0
laminas/laminas-stdlib Version ^3.1
neighborhoods/buphalo Version ^1.0
neighborhoods/datadog-component Version ^1.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 neighborhoods/prefab contains the following files

Loading the files please wait ....