Skip to content

Commit

Permalink
Fix: namespace and service provider (#7)
Browse files Browse the repository at this point in the history
* Added mac :DS_Store files to gitignore

* Added: Service Provider with package discovery in composer.json

* Fixed: Command being in correct namespace for following PSR-4

* Fixed: Naming of import for command in service provider

* Removed: Registering its own service provider. no need after adding extra step in composer

* Solves #6 
---------

Co-authored-by: Jonas Schelde <js@a-round.dk>
  • Loading branch information
scheldejonas and jsaround authored Oct 9, 2023
1 parent b7e5af8 commit 44cf42f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ psalm.xml
vendor
.php-cs-fixer.cache

.DS_Store
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
shell:=/bin/bash

composer_install:
@php81 composer install
17 changes: 13 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
},
"require-dev": {
"pestphp/pest": "^2.0",
"laravel/pint": "^2.3",
"spatie/ray": "^1.28"
"laravel/pint": "^v1.13.2",
"spatie/ray": "^1.28",
"illuminate/support": "^9.21|^10.0",
"illuminate/console": "^v9.21|^v10.0"
},
"autoload": {
"psr-4": {
Expand All @@ -45,5 +47,12 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
"prefer-stable": true,
"extra": {
"laravel": {
"providers": [
"EmilHorlyck\\LaravelPareto\\ServiceProvider"
]
}
}
}
4 changes: 2 additions & 2 deletions src/Commands/TestCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace EmilHorlyck\LaravelPareto;
namespace EmilHorlyck\LaravelPareto\Commands;

use Illuminate\Console\Command;

Expand All @@ -12,6 +12,6 @@ class TestCommand extends Command

public function handle(): int
{
this->info('Test command');
$this->info('Test command');
}
}
7 changes: 0 additions & 7 deletions src/LaravelPareto.php

This file was deleted.

28 changes: 28 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace EmilHorlyck\LaravelPareto;

use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use EmilHorlyck\LaravelPareto\Commands\TestCommand;

class ServiceProvider extends BaseServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
}

/**
* Bootstrap services.
*/
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->commands([
TestCommand::class
]);
}
}
}

0 comments on commit 44cf42f

Please sign in to comment.