Skip to content

Commit 8c2ab9a

Browse files
committed
Initial commit
0 parents  commit 8c2ab9a

15 files changed

+392
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/vendor
2+
node_modules/
3+
npm-debug.log
4+
yarn-error.log
5+
composer.lock
6+
*.meta.*
7+
_ide_*
8+
.phpunit.result.cache
9+

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelog
2+
3+
All notable changes to `vendor/package` will be documented in this file.
4+

README-en.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- [![Starts](https://img.shields.io/github/stars/miladimos/package-skeleton?style=flat&logo=github)](https://github.com/miladimos/package-skeleton/forks)
2+
- [![Forks](https://img.shields.io/github/forks/miladimos/package-skeleton?style=flat&logo=github)](https://github.com/miladimos/package-skeleton/stargazers)
3+
4+
- [فارسی](README.md)
5+
6+
# laravel Package
7+
A package for fun
8+
9+
### Installation
10+
11+
1. Run the command below to add this package:
12+
```
13+
composer require vendor/package
14+
```
15+
16+
2. Open your config/app.php and add the following to the providers array:
17+
```php
18+
Vendor\Package\Providers\PackageServiceProvider::class,
19+
```
20+
21+
3. Run the command below to publish the package config file config/package.php:
22+
```
23+
php artisan vendor:publish
24+
```

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- [![Starts](https://img.shields.io/github/stars/miladimos/laravel-?style=flat&logo=github)](https://github.com/miladimos/laravel-/forks)
2+
- [![Forks](https://img.shields.io/github/forks/miladimos/laravel-?style=flat&logo=github)](https://github.com/miladimos/laravel-/stargazers)
3+
4+
5+
- [English](README-en.md)
6+
7+
# پکیج لاراولی
8+
یه پکیج خفن
9+
10+
11+
### نصب
12+
13+
1. برای نصب در مسیر روت پروژه خود دستور زیر را در ریشه پروژه اجرا کنید
14+
```
15+
composer require miladimos/laravel-
16+
```
17+
18+
2. Open your config/app.php and add the following to the providers array:
19+
```php
20+
Miladimos\Package\Providers\PackageServiceProvider::class,
21+
```
22+
23+
3. Run the command below to publish the package config file config/package.php:
24+
```
25+
php artisan vendor:publish
26+
```

composer.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "miladimos/package-skeleton",
3+
"description": "test description",
4+
"homepage": "https://github.com/miladimos/package-skeleton",
5+
"type": "library",
6+
"keywords": [
7+
"laravel",
8+
"laravel-package",
9+
"laravel support",
10+
"lumen packages",
11+
"laravel packages",
12+
"lumen support"
13+
],
14+
"authors": [
15+
{
16+
"name": "miladimos",
17+
"email": "[email protected]",
18+
"role": "maintaner",
19+
"homepage": "https://github.com/miladimos"
20+
}
21+
],
22+
"autoload": {
23+
"psr-4": {
24+
"Miladimos\\Package\\": "src/"
25+
}
26+
},
27+
"autoload-dev": {
28+
"psr-4": {
29+
"Miladimos\\Package\\Tests\\": "tests"
30+
}
31+
},
32+
"extra": {
33+
"laravel": {
34+
"providers": [
35+
"PackageServiceProvider"
36+
],
37+
"aliases": {
38+
"Package": "Miladimos\\Package\\Facades\\PackageFacade"
39+
}
40+
}
41+
},
42+
"require": {
43+
"php": ">=7.2"
44+
},
45+
"require-dev": {
46+
"phpunit/phpunit": "^9.4"
47+
},
48+
"minimum-stability": "stable",
49+
"license": "MIT"
50+
}

config/config.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
// config file for vendor/package
4+
return [
5+
//
6+
];

database/create_tables_table.php.stub

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateTablesTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('tables', function (Blueprint $table) {
17+
$table->id();
18+
19+
$table->string('title');
20+
21+
$table->timestamps();
22+
});
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function down()
31+
{
32+
Schema::dropIfExists('tables');
33+
}
34+
}

phpunit.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
verbose="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false">
12+
<testsuites>
13+
<testsuite name="Test Suite">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory suffix=".php">src/</directory>
20+
</whitelist>
21+
</filter>
22+
<php>
23+
<env name="DB_CONNECTION" value="testing"/>
24+
</php>
25+
</phpunit>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
3+
namespace Miladimos\Package\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class InstallPackageCommand extends Command
8+
{
9+
protected $signature = 'package:install';
10+
11+
protected $description = 'Install the package Package';
12+
13+
public function handle()
14+
{
15+
$this->line("\t... Welcome To Package Installer ...");
16+
17+
18+
$this->info("Package Successfully Installed.\n");
19+
$this->info("\t\tGood Luck.");
20+
}
21+
22+
// //config
23+
// if (File::exists(config_path('package.php'))) {
24+
// $confirm = $this->confirm("package.php already exist. Do you want to overwrite?");
25+
// if ($confirm) {
26+
// $this->publishConfig();
27+
// $this->info("config overwrite finished");
28+
// } else {
29+
// $this->info("skipped config publish");
30+
// }
31+
// } else {
32+
// $this->publishConfig();
33+
// $this->info("config published");
34+
// }
35+
36+
// //assets
37+
// if (File::exists(public_path('package'))) {
38+
// $confirm = $this->confirm("package directory already exist. Do you want to overwrite?");
39+
// if ($confirm) {
40+
// $this->publishAssets();
41+
// $this->info("assets overwrite finished");
42+
// } else {
43+
// $this->info("skipped assets publish");
44+
// }
45+
// } else {
46+
// $this->publishAssets();
47+
// $this->info("assets published");
48+
// }
49+
50+
// //migration
51+
// if (File::exists(database_path("migrations/$migrationFile"))) {
52+
// $confirm = $this->confirm("migration file already exist. Do you want to overwrite?");
53+
// if ($confirm) {
54+
// $this->publishMigration();
55+
// $this->info("migration overwrite finished");
56+
// } else {
57+
// $this->info("skipped migration publish");
58+
// }
59+
// } else {
60+
// $this->publishMigration();
61+
// $this->info("migration published");
62+
// }
63+
64+
// $this->call('migrate');
65+
// }
66+
67+
// private function publishConfig()
68+
// {
69+
// $this->call('vendor:publish', [
70+
// '--provider' => "Miladimos\package\Providers\packageServiceProvider",
71+
// '--tag' => 'config',
72+
// '--force' => true
73+
// ]);
74+
// }
75+
76+
// private function publishMigration()
77+
// {
78+
// $this->call('vendor:publish', [
79+
// '--provider' => "Miladimos\package\Providers\packageServiceProvider",
80+
// '--tag' => 'migrations',
81+
// '--force' => true
82+
// ]);
83+
// }
84+
85+
// private function publishAssets()
86+
// {
87+
// $this->call('vendor:publish', [
88+
// '--provider' => "Miladimos\package\Providers\packageServiceProvider",
89+
// '--tag' => 'assets',
90+
// '--force' => true
91+
// ]);
92+
// }
93+
}

src/Facades/PackageFacade.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Miladimos\Package\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class PackageFacade extends Facade
8+
{
9+
protected static function getFacadeAccessor()
10+
{
11+
return 'package'; // TODO: Change the accessor name
12+
}
13+
}

src/Models/PackageModel.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Miladimos\Package\Models;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class PackageModel extends Model
8+
{
9+
/**
10+
* The table associated with the model.
11+
*
12+
* @var string
13+
*/
14+
protected $table = 'tables';
15+
16+
// protected $fillable = ['name'];
17+
18+
protected $guarded = [];
19+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace Miladimos\Package\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Miladimos\Package\Console\Commands\InstallPackageCommand;
7+
use Miladimos\Package\Facades\PackageFacade;
8+
9+
class PackageServiceProvider extends ServiceProvider
10+
{
11+
12+
public function register()
13+
{
14+
$this->mergeConfigFrom(__DIR__ . "/../../config/config.php", 'package');
15+
16+
$this->registerFacades();
17+
}
18+
19+
/**
20+
* Bootstrap services.
21+
*
22+
* @return void
23+
*/
24+
public function boot()
25+
{
26+
27+
if ($this->app->runningInConsole()) {
28+
$this->registerCommands();
29+
$this->registerPublishes();
30+
$this->publishConfig();
31+
}
32+
}
33+
34+
private function registerFacades()
35+
{
36+
$this->app->bind('package', function ($app) {
37+
return new PackageFacade();
38+
});
39+
}
40+
41+
private function registerPublishes()
42+
{
43+
$this->publishes([
44+
__DIR__ . '/../../config/config.php' => config_path('package.php')
45+
], 'package-config');
46+
}
47+
48+
private function registerCommands()
49+
{
50+
$this->commands([
51+
InstallPackageCommand::class,
52+
]);
53+
}
54+
55+
public function publishConfig()
56+
{
57+
$this->publishes([
58+
__DIR__ . '/../../config/package.php' => config_path('package.php')
59+
], 'package-config');
60+
}
61+
}

tests/Feature/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)