commit b439f877eea0ecaa2844c2bd0299166a39257e10 Author: Gertjan Krol Date: Sat Aug 20 18:01:10 2022 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c00e42 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.idea/ +/vendor/ +composer.lock +*cache* +*.log +*.tmp diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..69f458f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,88 @@ +stages: + - prepare + - test + +prepare:composer-install: + stage: prepare + tags: + - prepare + image: composer:2.4 + script: + - echo "Start composer install" + - composer install --no-scripts --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader + artifacts: + expire_in: 1h + paths: + - composer.lock + - vendor/ + interruptible: true + +test:composer-security-check: + stage: test + tags: + - test + needs: + - job: prepare:composer-install + artifacts: true + image: composer:2.4 + script: + - echo "Start package security check" + - composer security-checker + allow_failure: true + interruptible: true + +test:php-codesniffer: + stage: test + tags: + - test + needs: + - job: prepare:composer-install + artifacts: true + image: composer:2.4 + script: + - echo "Start PHP code sniffer" + - composer style + interruptible: true + +# https://github.com/overtrue/phplint +test:php-lint: + stage: test + tags: + - test + needs: + - job: prepare:composer-install + artifacts: true + image: composer:2.4 + script: + - composer lint + interruptible: true + except: + - /^v\d+\.\d+\.\d+$/ + +test:phpunit-tests: + stage: test + tags: + - test + needs: + - job: prepare:composer-install + artifacts: true + image: composer:2.4 + script: + - echo "Start PHPUnit tests" + - composer test + interruptible: true + +test:composer-require-checker: + stage: test + tags: + - test + needs: + - job: prepare:composer-install + artifacts: true + image: composer:2.4 + script: + - echo "Downloading Composer require checker" + - curl -OL https://github.com/maglnet/ComposerRequireChecker/releases/download/4.0.0/composer-require-checker.phar + - echo "Start Composer require checker" + - php composer-require-checker.phar check composer.json + interruptible: true diff --git a/.phplint.yml b/.phplint.yml new file mode 100644 index 0000000..0ea59b7 --- /dev/null +++ b/.phplint.yml @@ -0,0 +1,8 @@ +path: ./ +jobs: 10 +cache: cache/phplint +extensions: + - php +exclude: + - vendor +warning: false diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a46a5c5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog +All notable changes to this package will be documented in this file + +## Unreleased + +## 1.0.0 - 202X-XX-XX +- Initial release [major] \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..cc4c643 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,53 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +- **Follow the [Crawl Coding Standard](https://git.gertjankrol.nl/crawl/coding-standard)** - Basically run `composer style` before committing/pushing. + +- **Add tests!** + +- **Document any change in behaviour** - Make sure the `CHANGELOG.md`, `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **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](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e344d12 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Author + +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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7b4119e --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Laravel package skeleton + +[![Latest Version on Packagist](https://img.shields.io/packagist/v/gertjankrol/skeleton.svg?style=flat-square)](https://packagist.org/packages/gertjankrol/skeleton) +[![Total Downloads](https://img.shields.io/packagist/dt/gertjankrol/skeleton.svg?style=flat-square)](https://packagist.org/packages/gertjankrol/skeleton) + +This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors. + +## Installation + +You can install the package via composer: + +```bash +composer require gertjankrol/skeleton +``` + +## Usage + +```php +// Usage description here +``` + +### Testing + +```bash +composer test +``` + +### Changelog + +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. + +### Security + +If you discover any security related issues, please email security@gkcld.net instead of using the issue tracker. + +## Authors +- [Gertjan Krol](https://git.gertjankrol.nl/gertjan) + +## License + +The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..88dd982 --- /dev/null +++ b/composer.json @@ -0,0 +1,64 @@ +{ + "name": "gertjankrol/skeleton", + "description": "Laravel package skeleton", + "keywords": [ + "gertjankrol", + "crm", + "skeleton" + ], + "homepage": "https://git.gertjankrol.nl/gertjankrol/skeleton", + "license": "MIT", + "type": "library", + "authors": [ + { + "name": "Gertjan Krol", + "email": "hello@gertjankrol.nl" + } + ], + "require": { + "php": "^8.1", + "illuminate/support": "^8.0" + }, + "require-dev": { + "orchestra/testbench": "^6.24", + "enlightn/security-checker": "^1.10", + "crawl/coding-standard": "^1.0", + "mockery/mockery": "^1.5", + "overtrue/phplint": "^4.3", + "phpunit/phpunit": "^9.5" + }, + "autoload": { + "psr-4": { + "GertjanKrol\\Skeleton\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "GertjanKrol\\Skeleton\\Tests\\": "tests" + } + }, + "scripts": { + "lint": "vendor/bin/phplint ./ --exclude=vendor", + "style": "vendor/bin/phpcs --standard=phpcs.xml", + "fix-style": "vendor/bin/phpcbf --standard=phpcs.xml", + "security-checker": "vendor/bin/security-checker security:check composer.lock", + "test": "vendor/bin/phpunit --configuration phpunit.xml --colors=never" + }, + "config": { + "optimize-autoloader": true, + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, + "extra": { + "laravel": { + "providers": [ + "GertjanKrol\\Skeleton\\SkeletonServiceProvider" + ], + "aliases": { + "Skeleton": "GertjanKrol\\Skeleton\\SkeletonFacade" + } + } + } +} diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..cadb71c --- /dev/null +++ b/config/config.php @@ -0,0 +1,10 @@ + + + Crawl Coding Standard for Packages + + + + + + + + + + + + + config + database + resources + src + tests + diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..f466529 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,16 @@ + + + + + ./src + + + + + ./tests/ + + + + + + diff --git a/resources/assets/css/pkg-name.css b/resources/assets/css/pkg-name.css new file mode 100644 index 0000000..e69de29 diff --git a/resources/assets/js/pkg-name.js b/resources/assets/js/pkg-name.js new file mode 100644 index 0000000..e69de29 diff --git a/resources/lang/.gitkeep b/resources/lang/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/.gitkeep b/resources/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/Skeleton.php b/src/Skeleton.php new file mode 100644 index 0000000..6514232 --- /dev/null +++ b/src/Skeleton.php @@ -0,0 +1,10 @@ +loadMigrationsFrom($this->getPackagePath() . '/database/migrations'); + //$this->loadRoutesFrom($this->getPackagePath() . '/routes.php'); + //$this->loadTranslationsFrom($this->getPackagePath() . '/resources/lang', self::PACKAGE_NAME); + //$this->loadViewsFrom($this->getPackagePath() . '/resources/views', self::PACKAGE_NAME); + + if ($this->app->runningInConsole()) { + // Publish config + $this->publishes([ + $this->getPackagePath() . '/config/config.php' => config_path(self::PACKAGE_NAME . '.php'), + ], 'config'); + + // Publish assets + //$this->publishes([ + // $this->getPackagePath() . '/resources/assets' => public_path('vendor/' . self::PACKAGE_NAME), + //], ['assets', 'public']); + + // Publishing translation files + //$this->publishes([ + // $this->getPackagePath() . '/resources/lang' => resource_path('lang/vendor/' . self::PACKAGE_NAME), + //], 'lang'); + + // Publishing views + //$this->publishes([ + // $this->getPackagePath() . '/resources/views' => resource_path('views/vendor/' . self::PACKAGE_NAME), + //], 'views'); + + // Registering package commands + $this->commands(self::COMMANDS); + } + } + + /** + * Register the application services. + */ + public function register(): void + { + // Automatically apply the package configuration + $this->mergeConfigFrom($this->getPackagePath() . '/config/config.php', self::PACKAGE_NAME); + + // Register the main class to use with the facade + $this->app->singleton(self::PACKAGE_NAME, static function () { + return new Skeleton(); + }); + } + + private function getPackagePath(): string + { + return realpath(__DIR__ . '/..'); + } +} diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29