Skip to content

Commit 46bfa25

Browse files
refactor: revamp project
BREAKING CHANGE: Container can't be initialized empty
1 parent 2128cf4 commit 46bfa25

17 files changed

+4111
-78
lines changed

.gitattributes

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
/tests export-ignore
2-
/.gitattributes export-ignore
3-
/.gitignore export-ignore
4-
/.scrutinizer.yml export-ignore
5-
/LICENSE export-ignore
6-
/CODE_OF_CONDUCT.md export-ignore
7-
/CONTRIBUTING.md export-ignore
8-
/phpunit.xml export-ignore
9-
/README.md export-ignore
1+
/CODE_OF_CONDUCT.md export-ignore
2+
/Dockerfile export-ignore
3+
/README.md export-ignore
4+
/docker-compose.yml export-ignore
5+
/phpunit.xml export-ignore
6+
/tests export-ignore
7+
/CONTRIBUTING.md export-ignore
8+
/LICENSE export-ignore
9+
/phpstan.neon export-ignore
10+
/.travis.yml export-ignore

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.idea
2-
composer.lock
3-
composer.phar
41
/vendor/
2+
.php_cs.cache
3+
.phpunit.result.cache

.php_cs.dist

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()->in(__DIR__);
4+
5+
return PhpCsFixer\Config::create()
6+
->setFinder($finder)
7+
->setRules(array(
8+
'@Symfony' => true,
9+
'@Symfony:risky' => true,
10+
'@PHPUnit48Migration:risky' => true,
11+
'array_syntax' => array('syntax' => 'short'),
12+
'ordered_imports' => true,
13+
'protected_to_private' => false,
14+
'declare_strict_types' => true,
15+
'fully_qualified_strict_types' => true,
16+
'date_time_immutable' => true,
17+
'mb_str_functions' => true,
18+
'strict_param' => true,
19+
'native_function_invocation' => true,
20+
))
21+
->setRiskyAllowed(true);

.scrutinizer.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
sudo: required
2+
3+
language: generic
4+
5+
services:
6+
- docker
7+
8+
before_install:
9+
- docker build -t moon/container .
10+
- docker run --name container -itd -e "TRAVIS=$TRAVIS" -e "TRAVIS_JOB_ID=$TRAVIS_JOB_ID" moon/container bash
11+
12+
13+
script:
14+
- docker exec container /bin/sh -c "php vendor/bin/php-cs-fixer fix --dry-run --diff --config=.php_cs.dist"
15+
- docker exec container /bin/sh -c "php vendor/bin/phpunit --coverage-clover clover.xml"
16+
17+
after_success:
18+
- docker exec container /bin/sh -c "php vendor/bin/php-coveralls -x clover.xml -o coveralls-upload.json"

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ The Moon Container code of conduct is derived from the Ruby code of conduct. Any
66

77
- When interpreting the words and actions of others, participants should always assume good intentions.
88

9-
- Behavior which can be reasonably considered harassment will not be tolerated.
9+
- Behavior which can be reasonably considered harassment will not be tolerated.

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM composer:latest as composer
2+
FROM php:fpm
3+
4+
# Define ENVs and ARGs
5+
ARG XDEBUG_REMOTE_HOST=docker.for.mac.localhost
6+
ENV XDEBUG_CONFIGURATION_FILE='/usr/local/etc/php/conf.d/xdebug.ini'
7+
ENV OPCACHE_FILE=$PHP_INI_DIR/conf.d/opcache.ini
8+
9+
# Add the project to the container
10+
WORKDIR /moon
11+
ADD . /moon
12+
13+
# Install dependencies for PHP
14+
RUN apt-get update && \
15+
apt-get install -y git zlib1g-dev && \
16+
docker-php-ext-install zip
17+
18+
# Install dependecies (dev included)
19+
COPY --from=composer /usr/bin/composer /usr/bin/composer
20+
RUN composer install
21+
22+
# Install XDebug and add XDebug configurations
23+
RUN yes | pecl install xdebug
24+
RUN echo 'xdebug.idekey=MOON' >> $XDEBUG_CONFIGURATION_FILE && \
25+
echo 'xdebug.remote_enable=1' >> $XDEBUG_CONFIGURATION_FILE && \
26+
echo 'xdebug.remote_port=9090' >> $XDEBUG_CONFIGURATION_FILE && \
27+
echo 'xdebug.remote_connect_back=0' >> $XDEBUG_CONFIGURATION_FILE && \
28+
echo 'xdebug.remote_autostart=1' >> $XDEBUG_CONFIGURATION_FILE && \
29+
echo 'xdebug.remote_log="/var/log/xdebug/xdebug.log"' >> $XDEBUG_CONFIGURATION_FILE && \
30+
echo "xdebug.remote_host=$XDEBUG_REMOTE_HOST" >> $XDEBUG_CONFIGURATION_FILE && \
31+
echo ';;settings for profiling' >> $XDEBUG_CONFIGURATION_FILE && \
32+
echo 'xdebug.profiler_enable_trigger=1' >> $XDEBUG_CONFIGURATION_FILE && \
33+
echo 'xdebug.profiler_output_name=xdebug.out.%t' >> $XDEBUG_CONFIGURATION_FILE && \
34+
echo 'xdebug.profiler_output_dir="/tmp/xdebug"' >> $XDEBUG_CONFIGURATION_FILE && \
35+
echo 'xdebug.profiler_enable_trigger=1' >> $XDEBUG_CONFIGURATION_FILE && \
36+
echo 'xdebug.trace_enable_trigger=1' >> $XDEBUG_CONFIGURATION_FILE && \
37+
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" >> $XDEBUG_CONFIGURATION_FILE
38+
39+
RUN mkdir /var/log/xdebug && chmod 0777 /var/log/xdebug

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016 Moon
3+
Copyright (c) 2018 Moon
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Moon - Container
22

3-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/moon-php/container/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/moon-php/container/?branch=master)
4-
[![Code Coverage](https://scrutinizer-ci.com/g/moon-php/container/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/moon-php/container/?branch=master)
5-
[![Build Status](https://scrutinizer-ci.com/g/moon-php/container/badges/build.png?b=master)](https://scrutinizer-ci.com/g/moon-php/container/build-status/master)
3+
[![Coverage Status](https://coveralls.io/repos/github/moon-php/container/badge.svg)](https://coveralls.io/github/moon-php/container)
4+
[![Build Status](https://travis-ci.org/moon-php/container.svg?branch=master)](https://travis-ci.org/moon-php/container)
5+
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
6+
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)
67

78
## Official Documentation
89

@@ -33,4 +34,4 @@ If you discover security related issues, please email damianopetrungaro@gmail.co
3334

3435
## License
3536

36-
The Moon Container is licensed under the MIT license. See [License File](LICENSE.md) for more information.
37+
The Moon Container is licensed under the MIT license. See [License File](LICENSE) for more information.

composer.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
"php": ">=7.1"
77
},
88
"require-dev": {
9-
"phpunit/phpunit": "^6.1"
9+
"roave/security-advisories": "dev-master",
10+
"friendsofphp/php-cs-fixer": "^2.12",
11+
"damianopetrungaro/php-commitizen": "^0.1.2",
12+
"phpstan/phpstan": "^0.10.1",
13+
"php-coveralls/php-coveralls": "^2.1",
14+
"phpunit/phpunit": "^7.3"
1015
},
1116
"authors": [
1217
{
@@ -21,7 +26,19 @@
2126
},
2227
"autoload-dev": {
2328
"psr-4": {
24-
"Moon\\Container\\Unit\\": "tests/Unit/"
29+
"Moon\\Container\\": "tests/Unit/"
2530
}
31+
},
32+
"scripts": {
33+
"inspire": "curl -s https://favqs.com/api/qotd | json_pp | awk -F ':[ \t]*' '/^.*\"body\"/ {print $2}'",
34+
"fix": "@php vendor/bin/php-cs-fixer fix --config=.php_cs.dist",
35+
"tests": "@php vendor/bin/phpunit",
36+
"analyse": "@php vendor/bin/phpstan analyse src tests"
37+
},
38+
"scripts-descriptions": {
39+
"inspire": "Will print an inspiring quote",
40+
"fix": "Clean and optimize src and tests directories",
41+
"tests": "Run unit tests",
42+
"analyse": "Analyse project quality using PHPStan"
2643
}
2744
}

0 commit comments

Comments
 (0)