Skip to content

Instantly share code, notes, and snippets.

@atomjoy
Last active May 22, 2025 14:02
Show Gist options
  • Save atomjoy/fc59411f26d00b0b278ad540938fc622 to your computer and use it in GitHub Desktop.
Save atomjoy/fc59411f26d00b0b278ad540938fc622 to your computer and use it in GitHub Desktop.
Laravel package development on localhost.
{
"require": {
"php": "^8.2",
"laravel/framework": "^12.0",
"atomjoy/payu": "dev-main"
},
"repositories": [
{
"type": "path",
"url": "packages/atomjoy/payu"
}
]
}
{
"name": "atomjoy/payu",
"description": "Laravel package library",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Atomjoy",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"openpayu/openpayu": "2.3.*"
},
"autoload": {
"classmap": [
"src/"
],
"psr-4": {
"Payu\\": "src/",
"Database\\Factories\\": "database/factories/",
"Database\\Migrations\\": "database/migrations/",
"Database\\Seeders\\": "database/seeders/"
}
},
"extra": {
"laravel": {
"providers": [
"Payu\\PayuServiceProvider"
],
"aliases": {
"Payu": "Payu\\Facades\\Payu"
}
}
}
}
<?php
namespace Atomjoy\Apilogin;
use Atomjoy\Apilogin\Http\Middleware\ApiloginMiddleware;
use Atomjoy\Apilogin\Http\Middleware\ApiloginAuthMiddleware;
use Atomjoy\Apilogin\Http\Middleware\ApiloginAuthAdminMiddleware;
use Atomjoy\Apilogin\Providers\AuthServiceProvider;
use Atomjoy\Apilogin\Providers\EventServiceProvider;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Http\Kernel;
use Spatie\Permission\Middleware\RoleMiddleware;
use Spatie\Permission\Middleware\PermissionMiddleware;
use Spatie\Permission\Middleware\RoleOrPermissionMiddleware;
// Package path: src/ApiloginServiceProvider.php
class ApiloginServiceProvider extends ServiceProvider
{
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'apilogin');
$this->app->register(EventServiceProvider::class);
// $this->app->register(AuthServiceProvider::class);
if (config('apilogin.overwrite_disk_s3', true)) {
$this->app->config["filesystems.disks.s3"] = [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
'throw' => false,
];
}
// Admin guard and provider
$this->app->config["auth.guards.admin"] = [
'driver' => 'session',
'provider' => 'admins',
];
$this->app->config["auth.providers.admins"] = [
'driver' => 'eloquent',
'model' => \Atomjoy\Apilogin\Models\Admin::class,
];
}
public function boot(Kernel $kernel)
{
$this->app['router']->aliasMiddleware('apilogin', ApiloginMiddleware::class);
$this->app['router']->aliasMiddleware('apilogin_is_admin', ApiloginAuthAdminMiddleware::class);
// Spatie permissions
if (config('apilogin.load_permissions', true)) {
$this->app['router']->aliasMiddleware('role', RoleMiddleware::class);
$this->app['router']->aliasMiddleware('permission', PermissionMiddleware::class);
$this->app['router']->aliasMiddleware('role_or_permission', RoleOrPermissionMiddleware::class);
}
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'apilogin');
if (config('apilogin.load_migrations', true)) {
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
}
if (config('apilogin.load_translations', true)) {
$this->loadTranslationsFrom(__DIR__ . '/../lang', 'apilogin');
$this->loadJsonTranslationsFrom(__DIR__ . '/../lang');
}
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../config/config.php' => config_path('apilogin.php'),
], 'apilogin-config');
$this->publishes([
__DIR__ . '/../resources/views' => resource_path('views/vendor/apilogin')
], 'apilogin-views');
$this->publishes([
__DIR__ . '/../lang' => base_path('lang/vendor/apilogin')
], 'apilogin-lang');
$this->publishes([
// __DIR__.'/../database/migrations/create_table.php.stub' => $this->getMigrationFileName('create_table.php'),
], 'apilogin-migrations');
}
}
}
<?php
namespace Migratio;
use Illuminate\Support\ServiceProvider;
// Package path: src/MigratioServiceProvider.php
class MigratioServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
$path = database_path('migrations');
$dirs = glob($path . '/*', GLOB_ONLYDIR);
$arr = array_merge([$path], $dirs);
$this->loadMigrationsFrom($arr);
}
}
<?php
namespace Payu;
use Illuminate\Support\ServiceProvider;
use Payu\Gateways\PayuPaymentGateway;
use Payu\Http\Middleware\PayuMiddleware;
use Payu\Providers\PayuEventServiceProvider;
use Payu\Payu;
// Package path: src/PayuServiceProvider.php
class PayuServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'payu');
// Enable payu gateway
if (config('payu.enable') == true) {
// Middleware
$this->app['router']->aliasMiddleware('payu', PayuMiddleware::class);
// Facade
$this->app->bind('payu', function ($app) {
return new Payu();
});
// Service
$this->app->bind(PayuPaymentGateway::class, function ($app) {
return new PayuPaymentGateway();
});
// Events
if (config('payu.env') == 'sandbox') {
// Event service
$this->app->register(PayuEventServiceProvider::class);
}
}
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'payu');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'payu');
if (config('payu.migrations') == true) {
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
}
if (config('payu.routes') == true) {
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
}
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../config/config.php' => config_path('payu.php'),
__DIR__ . '/../public' => public_path('vendor/payu'),
], 'payu-config');
$this->publishes([
__DIR__ . '/../resources/views' => resource_path('views/vendor/payu'),
__DIR__ . '/../resources/lang' => $this->app->langPath('vendor/payu'),
], 'payu-pages');
$this->publishes([
__DIR__ . '/../database/migrations' => database_path('/migrations'),
], 'payu-migrations');
$this->publishes([
__DIR__ . '/../public' => public_path('vendor/payu'),
], 'payu-public');
$this->publishes([
__DIR__ . '/../tests/Payu' => base_path('tests/Payu')
], 'payu-tests');
}
}
}
<?php
namespace Proton;
use Illuminate\Support\ServiceProvider;
// Package path: src/ProtonServiceProvider.php
class ProtonServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
// Add config
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'proton');
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
// Email views
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'proton');
// Locales
$this->loadTranslationsFrom(__DIR__ . '/../lang', 'proton');
$this->loadJsonTranslationsFrom(__DIR__ . '/../lang');
// Publish
if ($this->app->runningInConsole()) {
// Copy images
$this->publishes([
__DIR__ . '/../public' => public_path('vendor/proton'),
], 'proton-mail');
// Edit proton view
$this->publishes([
__DIR__ . '/../resources/views' => resource_path('views/vendor/proton')
], 'proton-views');
// Locales
$this->publishes([
__DIR__ . '/../lang' => base_path('lang/vendor/proton'),
], 'proton-lang');
// Config
$this->publishes([
__DIR__ . '/../config/config.php' => config_path('proton.php'),
], 'proton-config');
}
}
}
<?php
namespace Atomjoy\Sms;
use Atomjoy\Sms\Providers\SmsChannelProvider;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Http\Kernel;
// Package path: src/SmsServiceProvider.php
class SmsServiceProvider extends ServiceProvider
{
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'smsapisms');
// Load package service provider
$this->app->register(SmsChannelProvider::class);
}
public function boot(Kernel $kernel)
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../config/config.php' => config_path('smsapisms.php'),
], 'smsapisms-config');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment