Coder Social home page Coder Social logo

Comments (4)

anabeto93 avatar anabeto93 commented on July 18, 2024 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.

hwbrzzl avatar hwbrzzl commented on July 18, 2024

I checked the Laravel document and I found some components that we need to implement in the first version:

  1. Service Providers
  2. Configuration, not contain Default Package Configuration
  3. Routes
  4. Migrations
  5. Commands
  6. Public Assets
  7. 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.

anabeto93 avatar anabeto93 commented on July 18, 2024

Suggested plan for developing the important components for a third party package for goravel.

  1. Service Providers: Implement service providers to allow packages to register their services, event listeners, and middleware with the goravel/framework.

  2. Configuration: Set up a configuration system for third-party packages, but exclude default package configuration for now, as suggested.

  3. Routes: Enable packages to define their own routes that integrate seamlessly with the goravel/framework.

  4. Migrations: Implement migrations to allow packages to manage their database schema changes over time.

  5. Commands: Enable packages to define custom console commands that can be executed using the goravel/framework CLI.

  6. Public Assets: Establish a system for packages to publish and manage their public assets, such as CSS, JavaScript, and images.

  7. 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:

  1. Goravel framework itself needs a BaseServiceProvider that implements the contracts.ServiceProvider that all other service providers can "compose"/inherit
  2. 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
  3. 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 or TOML file, like the composer.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.

hwbrzzl avatar hwbrzzl commented on July 18, 2024

Thanks for your summary!
About your notes:

  1. Sounds good, let's make a simple example first when implementing;
  2. I think one or more service providers should be supported, will have wider adaptability.
  3. Yes, we can have it in the future, but not now;

from goravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.