Skip to content

Commit eeae647

Browse files
author
Marco Bunge
committed
Prepare package for development
0 parents  commit eeae647

File tree

12 files changed

+423
-0
lines changed

12 files changed

+423
-0
lines changed

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.travis.yml export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/tests export-ignore

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
composer.lock
2+
vendor/
3+
.idea/
4+
.vagrant/
5+
tests/coverage

.travis.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
sudo: false
2+
3+
language: php
4+
5+
php:
6+
- 5.5
7+
- 5.6
8+
- 7.0
9+
- hhvm
10+
11+
matrix:
12+
fast_finish: true
13+
allow_failures:
14+
php: 7.0
15+
16+
cache:
17+
directories:
18+
- $HOME/.composer/cache
19+
20+
before_install:
21+
- travis_retry composer self-update
22+
23+
install:
24+
- if [[ $(phpenv version-name) == '5.6' ]]; then composer require satooshi/php-coveralls:dev-master -n ; fi
25+
- travis_retry composer install --no-interaction --prefer-dist
26+
27+
script:
28+
- if [[ $(phpenv version-name) == '5.6' ]]; then phpunit --coverage-clover build/logs/clover.xml ; fi
29+
- if [[ $(phpenv version-name) != '5.6' ]]; then phpunit ; fi
30+
31+
after_success:
32+
- if [[ $(phpenv version-name) == '5.6' ]]; then php vendor/bin/coveralls -v ; fi

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Hawkbit Persistence Changelog
2+
3+
## 1.0.0
4+
5+
### Added
6+
7+
- Add persistence service, service provider and documentation
8+

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
We accept contributions via Pull Requests on [Github](https://github.com/HawkBitPhP/persistence).
6+
7+
## Pull Requests
8+
9+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
10+
11+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
12+
13+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
14+
15+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
16+
17+
- **Create feature branches** - Don't ask us to pull from your master branch.
18+
19+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
20+
21+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
22+
23+
## Install
24+
25+
``` bash
26+
$ composer install --dev
27+
```
28+
29+
## Running Tests
30+
31+
``` bash
32+
$ composer test
33+
```
34+
35+
**Happy coding**!

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Marco Bunge
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Hawkbit Persistence
2+
3+
[![Latest Version on Packagist][ico-version]][link-packagist]
4+
[![Software License][ico-license]](LICENSE.md)
5+
[![Build Status][ico-travis]][link-travis]
6+
[![Total Downloads][ico-downloads]][link-downloads]
7+
[![Coverage Status][ico-coveralls]][link-coveralls]
8+
9+
Persistence layer for Hawkbit PSR-7 Micro PHP framework.
10+
Hawkbit Persitence uses factories of `dasprid/container-interop-doctrine` and wraps them with in a PersistenceService
11+
12+
## Install
13+
14+
### Using Composer
15+
16+
Hawkbit Persistence is available on [Packagist][link-packagist] and can be installed using [Composer](https://getcomposer.org/). This can be done by running the following command or by updating your `composer.json` file.
17+
18+
```bash
19+
composer require hawkbit/persistence
20+
```
21+
22+
composer.json
23+
24+
```javascript
25+
{
26+
"require": {
27+
"hawkbit/persistence": "~1.0"
28+
}
29+
}
30+
```
31+
32+
Be sure to also include your Composer autoload file in your project:
33+
34+
```php
35+
<?php
36+
37+
require __DIR__ . '/vendor/autoload.php';
38+
```
39+
40+
### Downloading .zip file
41+
42+
This project is also available for download as a `.zip` file on GitHub. Visit the [releases page](https://github.com/hawkbit/persistence/releases), select the version you want, and click the "Source code (zip)" download button.
43+
44+
### Requirements
45+
46+
The following versions of PHP are supported by this version.
47+
48+
* PHP 5.5
49+
* PHP 5.6
50+
* PHP 7.0
51+
* HHVM
52+
53+
## Setup
54+
55+
Setup with an existing application configuration (we refer to [tests/assets/config.php](tests/assets/config.php))
56+
57+
```php
58+
<?php
59+
60+
use \Hawkbit\Application;
61+
use \Hawkbit\Persistence\PersistenceService;
62+
use \Hawkbit\Persistence\PersistenceServiceProvider;
63+
64+
$app = new Application(require_once __DIR__ . '/config.php');
65+
66+
$entityFactoryClass = \ContainerInteropDoctrine\EntityManagerFactory::class;
67+
68+
$persistenceService = new PersistenceService([
69+
PersistenceService::resolveFactoryAlias($entityFactoryClass) => [$entityFactoryClass]
70+
], $app);
71+
72+
$app->register(new PersistenceServiceProvider($persistenceService));
73+
```
74+
75+
## Examples
76+
77+
### Full configuration
78+
79+
A full configuration is available on [DASPRiD/container-interop-doctrine/example/full-config.php](https://github.com/DASPRiD/container-interop-doctrine/blob/master/example/full-config.php).
80+
Refer to [container-interop-doctrine Documentation](https://github.com/DASPRiD/container-interop-doctrine) for further instructions on factories.
81+
82+
### Persistence from Hawbit Application
83+
84+
```php
85+
<?php
86+
87+
/** @var \Hawkbit\Persistence\PersistenceServiceInterface $persistence */
88+
$persistence = $app[\Hawkbit\Persistence\PersistenceServiceInterface::class];
89+
90+
$em = $persistence->getEntityManager();
91+
92+
// or with from specific connection
93+
$em = $persistence->getEntityManager('connectionname');
94+
95+
```
96+
97+
### Persistence in a Hawkbit controller
98+
99+
Access persistence service in controller. Hawbit is inject classes to controllers by default.
100+
101+
```php
102+
<?php
103+
104+
use \Hawkbit\Persistence\PersistenceServiceInterface;
105+
106+
class MyController{
107+
108+
/**
109+
* @var \Hawkbit\Persistence\PersistenceServiceInterface
110+
*/
111+
private $persistence = null;
112+
113+
public function __construct(PersistenceServiceInterface $persistence){
114+
$this->persistence = $persistence;
115+
}
116+
117+
public function index(){
118+
$em = $this->persistence->getEntityManager();
119+
120+
// or with from specific connection
121+
$em = $this->persistence->getEntityManager('connectionname');
122+
}
123+
}
124+
```
125+
126+
## Change log
127+
128+
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
129+
130+
## Testing
131+
132+
``` bash
133+
$ composer test
134+
```
135+
136+
## Contributing
137+
138+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
139+
140+
## Security
141+
142+
If you discover any security related issues, please email <[email protected]> instead of using the issue tracker.
143+
144+
## Credits
145+
146+
- [Marco Bunge](https://github.com/mbunge)
147+
- [All contributors](https://github.com/hawkbit/persistence/graphs/contributors)
148+
149+
## License
150+
151+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
152+
153+
[ico-version]: https://img.shields.io/packagist/v/hawkbit/persistence.svg?style=flat-square
154+
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
155+
[ico-travis]: https://img.shields.io/travis/HawkBitPhp/hawkbit-persistence/master.svg?style=flat-square
156+
[ico-downloads]: https://img.shields.io/packagist/dt/hawkbit/persistence.svg?style=flat-square
157+
[ico-coveralls]: https://img.shields.io/coveralls/HawkBitPhp/hawkbit-persistence/master.svg?style=flat-square
158+
159+
[link-packagist]: https://packagist.org/packages/hawkbit/hawkbit
160+
[link-travis]: https://travis-ci.org/HawkBitPhp/hawkbit
161+
[link-downloads]: https://packagist.org/packages/hawkbit/hawkbit
162+
[link-author]: https://github.com/mbunge
163+
[link-contributors]: ../../contributors
164+
[link-coveralls]: https://coveralls.io/github/HawkBitPhp/hawkbit

composer.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "hawkbit/persistence",
3+
"type": "library",
4+
"description": "Persistence layer for Hawkbit PSR-7 Micro PHP framework",
5+
"keywords": [
6+
"doctrine",
7+
"orm",
8+
"persistence",
9+
"hawkbit"
10+
],
11+
"homepage": "https://github.com/HawkBitPhP",
12+
"license": "MIT",
13+
"authors": [
14+
{
15+
"name": "Marco Bunge",
16+
"email": "[email protected]"
17+
}
18+
],
19+
"require": {
20+
"php": ">=5.5.0",
21+
"league/plates": "~3.0",
22+
"robclancy/presenter": "~1.3.1",
23+
"hawkbit/hawkbit": "~2.0"
24+
},
25+
"require-dev": {
26+
"phpunit/phpunit": "~4.8"
27+
},
28+
"autoload": {
29+
"psr-4": {
30+
"Hawkbit\\Persistence\\": "src/"
31+
}
32+
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"Hawkbit\\Persistence\\Tests\\": "tests/"
36+
}
37+
},
38+
"scripts": {
39+
"test": [
40+
"cd vendor/phpunit/phpunit",
41+
"phpunit --configuration phpunit.xml"
42+
]
43+
}
44+
}

phpunit.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
>
13+
<testsuites>
14+
<testsuite name="Package Test Suite">
15+
<directory suffix=".php">./tests/</directory>
16+
<exclude>./tests/Stubs</exclude>
17+
</testsuite>
18+
</testsuites>
19+
</phpunit>

src/PersistenceServiceProvider.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: marco.bunge
5+
* Date: 14.10.2016
6+
* Time: 13:40
7+
*/
8+
9+
namespace Hawkbit\Persistence;
10+
11+
12+
use League\Container\Container;
13+
use League\Container\ServiceProvider\AbstractServiceProvider;
14+
use League\Container\ServiceProvider\BootableServiceProviderInterface;
15+
16+
class PersistenceServiceProvider extends AbstractServiceProvider
17+
{
18+
19+
protected $provides = [
20+
21+
];
22+
23+
/**
24+
* Use the register method to register items with the container via the
25+
* protected $this->container property or the `getContainer` method
26+
* from the ContainerAwareTrait.
27+
*
28+
* @return void
29+
*/
30+
public function register()
31+
{
32+
// TODO: Implement register() method.
33+
}
34+
}

0 commit comments

Comments
 (0)