Skip to content

Commit

Permalink
Rewriting as Laminas Project package
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Dec 31, 2019
1 parent 48cd400 commit 2f28daf
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
vendor/
composer.lock
/composer.lock
/vendor/
2 changes: 2 additions & 0 deletions COPYRIGHT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Copyright (c) 2019, Laminas Foundation.
All rights reserved. (https://getlaminas.org/)
16 changes: 8 additions & 8 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Copyright (c) 2014-2016, Zend Technologies USA, Inc.
Copyright (c) 2019, Laminas Foundation
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

- Neither the name of Zend Technologies USA, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
- Neither the name of Laminas Foundation nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Expand Down
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# StatusLib

This is a library designed to demonstrate an [Apigility](http://apigility.org/) "Code-Connected"
REST API, and has been written in parallel with the [Apigility documentation](https://github.com/zfcampus/apigility-documentation).
This is a library designed to demonstrate an [Laminas API Tools](https://api-tools.getlaminas.org/) "Code-Connected"
REST API, and has been written in parallel with the [Laminas API Tools documentation](https://github.com/laminas-api-tools/api-tools-documentation).

It uses the following components:

- [rhumsaa/uuid](https://github.com/ramsey/uuid), a library for generating and validating UUIDs.
- [zfcampus/zf-configuration](https://github.com/zfcampus/zf-configuration), used for providing PHP
- [laminas-api-tools/api-tools-configuration](https://github.com/laminas-api-tools/api-tools-configuration), used for providing PHP
files as one possible backend for reading/writing status messages.
- [zendframework/zend-config](https://framework.zend.com/) for the actual configuration writer used
by the `zf-configuration` module.
- [zendframework/zend-db](https://framework.zend.com/), used for providing a database table as a
- [laminas/laminas-config](https://getlaminas.org/) for the actual configuration writer used
by the `api-tools-configuration` module.
- [laminas/laminas-db](https://getlaminas.org/), used for providing a database table as a
backend for reading/writing status messages.
- [zendframework/zend-stdlib](https://framework.zend.com/), specifically the Hydrator subcomponent,
- [laminas/laminas-stdlib](https://getlaminas.org/), specifically the Hydrator subcomponent,
for casting data from arrays to objects, and for the `ArrayUtils` class, which provides advanced
array merging capabilities.
- [zendframework/zend-paginator](https://framework.zend.com/) for providing pagination.
- [laminas/laminas-paginator](https://getlaminas.org/) for providing pagination.

It is written as a Zend Framework module, but could potentially be dropped into other
It is written as a Laminas module, but could potentially be dropped into other
applications; use the `StatusLib\*Factory` classes to see how dependencies might be injected.

## Installation

Use [Composer](https://getcomposer.org/) to install the library in your application:

```console
$ composer require zfcampus/statuslib-example
$ composer require laminas-api-tools/statuslib-example
```

If you are using this as part of a Zend Framework or Apigility application, you
If you are using this as part of a Laminas or Laminas API Tools application, you
may need to enable the module in your `config/application.config.php` file, if
you are not using the [zend-component-installer](https://docs.zendframework.com/zend-component-installer/):
you are not using the [laminas-component-installer](https://docs.laminas.dev/laminas-component-installer/):

```php
return [
Expand All @@ -45,7 +45,7 @@ return [

## Configuration

When used as a Zend Framework module, you may define the following configuration values in order
When used as a Laminas module, you may define the following configuration values in order
to tell the library which adapter to use, and what options to pass to that adapter.

```php
Expand All @@ -64,7 +64,7 @@ to tell the library which adapter to use, and what options to pass to that adapt
]
```

For purposes of the Apigility examples, we suggest the following:
For purposes of the Laminas API Tools examples, we suggest the following:

- Create a PHP file in your application's `data/` directory named `statuslib.php` that returns an
array:
Expand Down Expand Up @@ -103,18 +103,18 @@ The schema can be either used directly by other databases, or easily modified to
databases.


## StatusLib in a New Zend Framework Project
## StatusLib in a New Laminas Project

1. Create a new Zend Framework project from scratch; we'll use `my-project` as our project folder:
1. Create a new Laminas project from scratch; we'll use `my-project` as our project folder:

```console
$ composer create-project zendframework/skeleton-application my-project
$ composer create-project laminas/skeleton-application my-project
```

2. Install the StatusLib module:

```console
$ composer require zfcampus/statuslib-example
$ composer require laminas-api-tools/statuslib-example
```

3. Build a DataSource
Expand All @@ -124,7 +124,7 @@ databases.
First, copy the sample array to the `data` directory of thet application:

```console
$ cp vendor/zfcampus/statuslib-example/data/sample-data/array-data.php data/status.data.php
$ cp vendor/laminas-api-tools/statuslib-example/data/sample-data/array-data.php data/status.data.php
```

Then, configure this datasource by setting up a `local.php` configuration file:
Expand All @@ -151,8 +151,8 @@ databases.
First, create a sqlite3 database, and fill it with the sample data:

```console
$ sqlite3 data/status.db < vendor/zfcampus/statuslib-example/data/statuslib.sqlite.sql
$ sqlite3 data/status.db < vendor/zfcampus/statuslib-example/data/sample-data/db-sqlite-insert.sql
$ sqlite3 data/status.db < vendor/laminas-api-tools/statuslib-example/data/statuslib.sqlite.sql
$ sqlite3 data/status.db < vendor/laminas-api-tools/statuslib-example/data/sample-data/db-sqlite-insert.sql
```
Then, configure this datasource by setting up a `local.php` configuration file:
Expand Down Expand Up @@ -189,8 +189,8 @@ databases.
// test.php
namespace StatusLib;

use Zend\Mvc\Application;
use Zend\Stdlib\ArrayUtils;
use Laminas\Mvc\Application;
use Laminas\Stdlib\ArrayUtils;

include 'vendor/autoload.php';

Expand Down
46 changes: 27 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
{
"name": "zfcampus/statuslib-example",
"description": "Library for use with Apigility documentation examples",
"type": "library",
"name": "laminas-api-tools/statuslib-example",
"description": "Library for use with Laminas API Tools documentation examples",
"license": "BSD-3-Clause",
"keywords": [
"apigility",
"framework",
"zf2"
"laminas",
"api-tools",
"framework"
],
"homepage": "http://apigility.org/",
"homepage": "https://api-tools.getlaminas.org",
"support": {
"email": "[email protected]",
"irc": "irc://irc.freenode.net/apigility",
"source": "https://github.com/zfcampus/statuslib-example",
"issues": "https://github.com/zfcampus/statuslib-example/issues"
"docs": "https://api-tools.getlaminas.org/documentation",
"issues": "https://github.com/laminas-api-tools/statuslib-example/issues",
"source": "https://github.com/laminas-api-tools/statuslib-example",
"rss": "https://github.com/laminas-api-tools/statuslib-example/releases.atom",
"chat": "https://laminas.dev/chat",
"forum": "https://discourse.laminas.dev"
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
},
"zf": {
"laminas": {
"module": "StatusLib"
}
},
"require": {
"php": "^5.6 || ^7.0",
"ramsey/uuid": "^2.8",
"zendframework/zend-config": "^3.1",
"zendframework/zend-db": "^2.8.2",
"zendframework/zend-paginator": "^2.7",
"zendframework/zend-hydrator": "^1.1 || ^2.0 || ^3.0",
"zendframework/zend-stdlib": "^2.7.7 || ^3.0.1",
"zfcampus/zf-configuration": "^1.0"
"laminas-api-tools/api-tools-configuration": "^1.0",
"laminas/laminas-config": "^3.1",
"laminas/laminas-db": "^2.8.2",
"laminas/laminas-hydrator": "^1.1 || ^2.0 || ^3.0",
"laminas/laminas-paginator": "^2.7",
"laminas/laminas-stdlib": "^2.7.7 || ^3.0.1",
"laminas/laminas-zendframework-bridge": "^1.0",
"ramsey/uuid": "^2.8"
},
"autoload": {
"psr-4": {
"StatusLib\\": "src/"
}
},
"replace": {
"zfcampus/statuslib-example": "self.version"
}
}
8 changes: 6 additions & 2 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @see https://github.com/laminas-api-tools/statuslib-example for the canonical source repository
* @copyright https://github.com/laminas-api-tools/statuslib-example/blob/master/COPYRIGHT.md
* @license https://github.com/laminas-api-tools/statuslib-example/blob/master/LICENSE.md New BSD License
*/

namespace StatusLib;
Expand All @@ -13,6 +15,8 @@
'service_manager' => [
'aliases' => [
Mapper::class => ArrayMapper::class,

// Legacy Zend Framework aliases
],
'factories' => [
ArrayMapper::class => ArrayMapperFactory::class,
Expand Down
14 changes: 8 additions & 6 deletions src/ArrayMapper.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?php

/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
* @see https://github.com/laminas-api-tools/statuslib-example for the canonical source repository
* @copyright https://github.com/laminas-api-tools/statuslib-example/blob/master/COPYRIGHT.md
* @license https://github.com/laminas-api-tools/statuslib-example/blob/master/LICENSE.md New BSD License
*/

namespace StatusLib;

use DomainException;
use InvalidArgumentException;
use Laminas\ApiTools\Configuration\ConfigResource;
use Laminas\Hydrator\ObjectProperty;
use Laminas\Hydrator\ObjectPropertyHydrator;
use Laminas\Stdlib\ArrayUtils;
use Rhumsaa\Uuid\Uuid;
use Traversable;
use Zend\Hydrator\ObjectProperty;
use Zend\Hydrator\ObjectPropertyHydrator;
use Zend\Stdlib\ArrayUtils;
use ZF\Configuration\ConfigResource;

/**
* Mapper implementation using a file returning PHP arrays
Expand Down
12 changes: 7 additions & 5 deletions src/ArrayMapperFactory.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
* @see https://github.com/laminas-api-tools/statuslib-example for the canonical source repository
* @copyright https://github.com/laminas-api-tools/statuslib-example/blob/master/COPYRIGHT.md
* @license https://github.com/laminas-api-tools/statuslib-example/blob/master/LICENSE.md New BSD License
*/

namespace StatusLib;

use DomainException;
use Zend\Config\Writer\PhpArray as ConfigWriter;
use ZF\Configuration\ConfigResource;
use Laminas\ApiTools\Configuration\ConfigResource;
use Laminas\Config\Writer\PhpArray as ConfigWriter;

/**
* Service factory for the ArrayMapper
Expand All @@ -18,7 +20,7 @@
* to a valid filesystem path of a PHP file that will return an array.
*
* Passes the data from the file, the path to the file, and a PhpArray config
* writer to a ZF\Configuration\ConfigResource instance, and passes the data
* writer to a Laminas\ApiTools\Configuration\ConfigResource instance, and passes the data
* and the ConfigResource instance to the ArrayMapper.
*/
class ArrayMapperFactory
Expand Down
8 changes: 5 additions & 3 deletions src/Collection.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php

/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
* @see https://github.com/laminas-api-tools/statuslib-example for the canonical source repository
* @copyright https://github.com/laminas-api-tools/statuslib-example/blob/master/COPYRIGHT.md
* @license https://github.com/laminas-api-tools/statuslib-example/blob/master/LICENSE.md New BSD License
*/

namespace StatusLib;

use Zend\Paginator\Paginator;
use Laminas\Paginator\Paginator;

/**
* Collection of StatusLib Entity objects
Expand Down
6 changes: 4 additions & 2 deletions src/Entity.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
* @see https://github.com/laminas-api-tools/statuslib-example for the canonical source repository
* @copyright https://github.com/laminas-api-tools/statuslib-example/blob/master/COPYRIGHT.md
* @license https://github.com/laminas-api-tools/statuslib-example/blob/master/LICENSE.md New BSD License
*/

namespace StatusLib;
Expand Down
12 changes: 7 additions & 5 deletions src/HydratingArrayPaginator.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
* @see https://github.com/laminas-api-tools/statuslib-example for the canonical source repository
* @copyright https://github.com/laminas-api-tools/statuslib-example/blob/master/COPYRIGHT.md
* @license https://github.com/laminas-api-tools/statuslib-example/blob/master/LICENSE.md New BSD License
*/

namespace StatusLib;

use Laminas\Hydrator\HydratorInterface;
use Laminas\Paginator\Adapter\ArrayAdapter as ArrayPaginator;
use stdClass;
use Zend\Paginator\Adapter\ArrayAdapter as ArrayPaginator;
use Zend\Hydrator\HydratorInterface;

/**
* Specialized Zend\Paginator\Adapter\ArrayAdapter instance for returning
* Specialized Laminas\Paginator\Adapter\ArrayAdapter instance for returning
* hydrated entities.
*/
class HydratingArrayPaginator extends ArrayPaginator
Expand Down
6 changes: 4 additions & 2 deletions src/MapperInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
* @see https://github.com/laminas-api-tools/statuslib-example for the canonical source repository
* @copyright https://github.com/laminas-api-tools/statuslib-example/blob/master/COPYRIGHT.md
* @license https://github.com/laminas-api-tools/statuslib-example/blob/master/LICENSE.md New BSD License
*/

namespace StatusLib;
Expand Down
8 changes: 5 additions & 3 deletions src/Module.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @see https://github.com/laminas-api-tools/statuslib-example for the canonical source repository
* @copyright https://github.com/laminas-api-tools/statuslib-example/blob/master/COPYRIGHT.md
* @license https://github.com/laminas-api-tools/statuslib-example/blob/master/LICENSE.md New BSD License
*/

namespace StatusLib;

/**
* ZF2 module
* Laminas module
*/
class Module
{
Expand Down
Loading

0 comments on commit 2f28daf

Please sign in to comment.