Comments (4)
@hwbrzzl , I created a new issue which I think holds more priority to this current issue. I think if we can have the IoC implementation done, this current issue would become so much easier to do. I took a look at the laravel vendor/laravel/framework/src/Illuminate/Contracts/Container/
directory and everything inside it is quite easy to implement in golang on the goravel framework. The implementation is found in vendor/laravel/framework/src/Illuminate/Container/Container.php
and it is not complicated to replicate. I also noticed the Illuminate\Contracts\Foundation
interface extends the Container
interface and the Application
implementation also extends the Container
implementation.
from goravel.
I checked the Laravel document and I found some components that we need to implement in the first version:
- Service Providers
- Configuration, not contain Default Package Configuration
- Routes
- Migrations
- Commands
- Public Assets
- Publishing File Groups
There is a key point: we need a standard, let the third package can use the basic ability of goravel/framework.
from goravel.
Suggested plan for developing the important components for a third party package for goravel.
-
Service Providers: Implement service providers to allow packages to register their services, event listeners, and middleware with the goravel/framework.
-
Configuration: Set up a configuration system for third-party packages, but exclude default package configuration for now, as suggested.
-
Routes: Enable packages to define their own routes that integrate seamlessly with the goravel/framework.
-
Migrations: Implement migrations to allow packages to manage their database schema changes over time.
-
Commands: Enable packages to define custom console commands that can be executed using the goravel/framework CLI.
-
Public Assets: Establish a system for packages to publish and manage their public assets, such as CSS, JavaScript, and images.
-
Publishing File Groups: Implement a feature that allows package developers to define groups of files that can be published together.
Regarding the first component ServiceProvider
, I noticed that the stancl multitenancy package has two service providers. One in the assets/
directory, assets/TenancyServiceProvider.php and the one in the main src/
directory, src/TenancyServiceProvider.php. The one in the assets/
is the one that is auto-discovered
and the one in the src/
is the one that actually does the work of publishing routes/
, migrations/
, configs/
, etc. All other commands of the Tenancy package depended on this src/
service provider in order to be able to do things like tenancy:install
, where config is copied over, etc.
My notes here are:
- Goravel framework itself needs a
BaseServiceProvider
that implements thecontracts.ServiceProvider
that all other service providers can "compose"/inherit - A third party package developer needs 2 service providers, the publishable and configurable one, and the main "unpublishable" service provider that is responsible for doing the actual work of publishing assets, routes, configs, etc
- Goravel needs a way to "auto-discover" packages but this is not necessarily important at this time. It is going to be a little bit complex but I'll expand on this later. We would have to create a requirement for a
JSON
,YAML
orTOML
file, like thecomposer.json
in laravel packages to enable this auto-discovery. Top of head example{ "providers": [ "github.com/vendor/package/package_service_provider.go" ], "aliases": { "Package": "github.com/vendor/package/facades/package_service_provider_facade.go" } }
from goravel.
Thanks for your summary!
About your notes:
- Sounds good, let's make a simple example first when implementing;
- I think one or more service providers should be supported, will have wider adaptability.
- Yes, we can have it in the future, but not now;
from goravel.
Related Issues (20)
- ✨ [Feature] ctx.Request() supports get multiple files directly HOT 1
- ✨ [Feature] String helpers(example Str::uuid() in laravel) HOT 4
- 🐛 [Bug] InputArray returns a wrong value when requesting by form HOT 2
- ✨ [Feature] jwt refresh token
- ✨ [Feature] Add json tag for orm.Model HOT 1
- ✨ [Feature] Add two new configurations for queue HOT 1
- 🐛 [Bug] Model的Retrieved event不会被触发 HOT 3
- ✨ [Feature] enhance the ability of the command feature HOT 1
- 🐛 [Bug] data error when calling facades.Auth().Parse() multiple times with different guard HOT 1
- ✨ [Feature] The queue log needs to be controled by APP_DEBUG HOT 1
- 🐛 [Bug] The context that set by facades.Orm().WithContext() isn't passed to orm events HOT 1
- ✨ [Feature] Supports configuring the json serialization/deserialization package in config/app.go HOT 2
- 🐛 [Bug] Minio does not implement filesystem.Driver HOT 2
- ✨ [Feature] Use contributors api to automatically generate contributors images in README HOT 4
- 🐛 [Bug] The new line print of Log is incorrect HOT 1
- ✨ [Feature] The trace of log can be clicked as a link HOT 1
- ✨ [Feature] Add a -f flag for make commands, to avoid cover the existing file by mistake HOT 1
- ✨ [Feature] Map the Installer to the Docs HOT 2
- ✨ [Feature] DB supports configure SSL HOT 1
- 🐛 [Bug] The traces don't cleaned when calling Log.Info after Log.Error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goravel.