Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/first generate core package #1 #10

Merged
merged 10 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/vendor
composer.lock
composer.phar
.DS_Store
/node_modules
/public/storage
/storage/*.key
Thumbs.db
/bower_components

.env.backup
.idea
.vscode

.vagrant
Homestead.yaml
npm-debug.log

.phpunit.cache

/storage/.license
/storage/fonts
/storage/installing
/storage/installed
/log

package-lock.json
yarn.lock
/.sass-cache
42 changes: 42 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
build:
nodes:
analysis:
project_setup:
override: true
tests:
override: [ php-scrutinizer-run ]
environment:
php:
version: 8.0

checks:
php:
code_rating: true
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true

tools:
php_analyzer: true
php_code_coverage: true
php_code_sniffer:
config:
standard: PSR4
filter:
paths: [ 'src' ]
php_loc:
enabled: true
excluded_dirs: [ vendor ]
php_cpd:
enabled: true
excluded_dirs: [ vendor ]
5 changes: 5 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
preset: laravel

disabled:
- not_operator_with_successor_space
- function_declaration
Empty file added common/helpers.php
Empty file.
76 changes: 76 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"name": "cslant/blog-core",
"description": "Send notification from Gitlab and Github events to Telegram",
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
"keywords": [
"cslant",
"laravel",
"cslant-blog-api-package",
"cslant-blog-api",
"cslant-blog",
"cslant-api",
"cslant-package",
"blog-api-package",
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
"blog-core"
],
"homepage": "https://github.com/cslant/blog-core",
"license": "MIT",
"authors": [
{
"name": "Tan Nguyen",
"email": "[email protected]",
"homepage": "https://tanhongit.com",
"role": "Developer"
},
{
"name": "Xuan Thinh",
"email": "[email protected]",
"role": "Developer"
}
],
"autoload": {
"psr-4": {
"CSlant\\BlogApi\\": "src/"
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
}
},
"autoload-dev": {
"psr-4": {
"CSlant\\BlogApi\\Tests\\": "tests/"
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
}
},
"require": {
"php": "^8.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v3.0",
"nunomaduro/collision": "^7.10",
"nunomaduro/larastan": "^2.9",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3"
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse",
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
},
"support": {
"issues": "https://github.com/cslant/blog-core/issues"
},
"extra": {
"laravel": {
"providers": [
"CSlant\\BlogApi\\Providers\\BlogApiServiceProvider"
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
]
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
10 changes: 10 additions & 0 deletions config/blog-core.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$routePrefix = env('BLOG_API_ROUTE_PREFIX', 'api');

return [
'defaults' => [
/* Set route prefix for the blog API */
'route_prefix' => $routePrefix,
],
];
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions lang/en/blog-core.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'message' => 'Hello from the blog core!',
];
Empty file added phpstan-baseline.neon
Empty file.
11 changes: 11 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
includes:
- phpstan-baseline.neon

parameters:
level: 9
paths:
- src
- routes
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
20 changes: 20 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
colors="true"
processIsolation="false"
stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="CSlant Blog API Package">
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
24 changes: 24 additions & 0 deletions routes/blog-core.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Blog API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register bot routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Enjoy building your API!
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
|
*/

$routePrefix = config('blog-api.defaults.route_prefix');

Route::prefix($routePrefix)->name("$routePrefix.")->group(function () {
Route::get('/posts', function () {
return response()->json([
'message' => 'Hello from the blog API!',
]);
});
});
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
73 changes: 73 additions & 0 deletions src/Providers/BlogApiServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace CSlant\BlogApi\Providers;

use Illuminate\Support\ServiceProvider;

class BlogApiServiceProvider extends ServiceProvider
pxthinh marked this conversation as resolved.
Show resolved Hide resolved
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot(): void
{
$routePath = __DIR__.'/../../routes/blog-core.php';
if (file_exists($routePath)) {
$this->loadRoutesFrom($routePath);
}

$this->loadTranslationsFrom(__DIR__.'/../../lang', 'blog-core');

$this->registerCommands();

$this->registerAssetPublishing();
}

/**
* Register services.
*
* @return void
*/
public function register(): void
{
$configPath = __DIR__.'/../../config/blog-core.php';
$this->mergeConfigFrom($configPath, 'blog-core');
}

/**
* Get the services provided by the provider.
*
* @return array<string>|null
*/
public function provides(): ?array
{
return ['blog-core'];
}

/**
* @return void
*/
protected function registerCommands(): void
{
$this->commands([
//
]);
}

/**
* @return void
*/
protected function registerAssetPublishing(): void
{
$configPath = __DIR__.'/../../config/blog-core.php';
$this->publishes([
$configPath => config_path('blog-core.php'),
], 'config');

$this->publishes([
__DIR__.'/../../lang' => resource_path('lang/packages/blog-core'),
], 'lang');
}
}
Empty file added tests/IntegrationTest.php
Empty file.