Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
IonBazan committed Jul 15, 2020
0 parents commit bea7a8f
Show file tree
Hide file tree
Showing 16 changed files with 971 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
/.php_cs.dist export-ignore
/phpunit.xml.dist export-ignore
/infection.json.dist export-ignore
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Tests
on: [push, pull_request]
jobs:
php:
name: PHP ${{ matrix.php-versions }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions:
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
include:
- php-versions: '7.0'
composer-flags: '--prefer-lowest'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: json
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-versions }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php-versions }}-composer-
- name: Install Composer dependencies
run: composer update -n --prefer-dist ${{ matrix.composer-flags }}
- name: Run Tests
run: vendor/bin/simple-phpunit --coverage-clover coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
- name: Run mutation tests
if: ${{ matrix.php-versions == 7.4 }}
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
run: |
composer req infection/infection
vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=100 --min-msi=100 -s -j4
- name: Run phpstan
if: ${{ matrix.php-versions >= 7.1 && matrix.php-versions < 8.0 }}
run: |
composer req phpstan/phpstan
vendor/bin/phpstan analyse src -l 6
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/vendor
/composer.lock
/phpunit.xml
/.php_cs
/.php_cs.cache
/coverage.xml
/coverage/
/.phpunit.result.cache
/infection.log
11 changes: 11 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'@PHP70Migration' => true,
'ordered_imports' => true,
))
->setRiskyAllowed(true)
->setFinder(PhpCsFixer\Finder::create()->in(['src', 'tests']))
;
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Ion Bazan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Laravel Container Debug command

[![Latest version](https://img.shields.io/packagist/v/ion-bazan/laravel-container-debug.svg)](https://packagist.org/packages/ion-bazan/laravel-container-debug)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/IonBazan/laravel-container-debug/Tests)](https://github.com/IonBazan/laravel-container-debug/actions)
[![PHP version](https://img.shields.io/packagist/php-v/ion-bazan/laravel-container-debug.svg)](https://packagist.org/packages/ion-bazan/laravel-container-debug)
[![Codecov](https://img.shields.io/codecov/c/gh/IonBazan/laravel-container-debug)](https://codecov.io/gh/IonBazan/laravel-container-debug)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FIonBazan%2Flaravel-container-debug%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/IonBazan/laravel-container-debug/master)
[![Downloads](https://img.shields.io/packagist/dt/ion-bazan/laravel-container-debug.svg)](https://packagist.org/packages/ion-bazan/laravel-container-debug)
[![License](https://img.shields.io/packagist/l/ion-bazan/laravel-container-debug.svg)](https://packagist.org/packages/ion-bazan/laravel-container-debug)

Symfony-inspired package to list available services in Laravel IoC Container. Works with Laravel 5.4+, 6.x and 7.x.

# Installation

```bash
composer require --dev ion-bazan/laravel-container-debug
```

Thanks to Laravel's Package Auto-Discovery, you don't need to register the ServiceProvider.

## Laravel without auto-discovery

If you don't use auto-discovery, add the Service Provider to the `providers` array in your `config/app.php`:

```php
\IonBazan\Laravel\ContainerDebug\ServiceProvider::class,
```

## Lumen

For Lumen, register the Service Provider in your `bootstrap/app.php`:
```php
$app->register(\IonBazan\Laravel\ContainerDebug\ServiceProvider::class);
```

# Usage

**TL;DR:** `php artisan container:debug --help`

Usage is pretty straightforward:

- to list all services: `php artisan container:debug`
- to check specific service: `php artisan container:debug MyFooService`
- to list all tags with tagged services: `php artisan container:debug --tags`
- to list all services with tag: `php artisan container:debug --tag=foo`

The command does it best to find the service you want by stripping slashes in service names and looking for any occurrences of given name in service names.
For example, to display `service.foo` service information, simply use `php artisan container:debug foo`. If there are more services with the similar name, a prompt will be shown to choose the one you are looking for.

To get the class name of the service, it must be initialized. To check how much time it took for each service, you may use `--profile` option.
39 changes: 39 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "ion-bazan/laravel-container-debug",
"type": "library",
"description": "Lists available services in Laravel IoC Container. Works with Laravel 5.4+, 6.x and 7.x.",
"license": "MIT",
"authors": [
{
"name": "Ion Bazan",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.0",
"ext-json": "*",
"illuminate/console": "^5.4 || ^6.0 || ^7.0",
"illuminate/container": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"symfony/phpunit-bridge": "^4.4 || ^5.0"
},
"autoload": {
"psr-4": {
"IonBazan\\Laravel\\ContainerDebug\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"IonBazan\\Laravel\\ContainerDebug\\Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"IonBazan\\Laravel\\ContainerDebug\\ServiceProvider"
]
}
}
}
17 changes: 17 additions & 0 deletions infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "infection.log",
"badge": {
"branch": "master"
}
},
"mutators": {
"@default": true,
"CastString": false
}
}
30 changes: 30 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/bin/.phpunit/phpunit.xsd"
failOnRisky="true"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
>
<testsuites>
<testsuite name="Laravel Container Debug Test Suite">
<directory>tests</directory>
<file>tests/ServiceProviderTestCase.php</file>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<listeners>
<listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>

<logging>
<log type="coverage-clover" target="coverage.xml"/>
<log type="coverage-html" target="coverage"/>
</logging>
</phpunit>
Loading

0 comments on commit bea7a8f

Please sign in to comment.