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

[Proposal] Make workbench create packages with PSR4 structure #5643

Closed
johnpancoast opened this issue Sep 3, 2014 · 8 comments
Closed

[Proposal] Make workbench create packages with PSR4 structure #5643

johnpancoast opened this issue Sep 3, 2014 · 8 comments

Comments

@johnpancoast
Copy link

I'm new to laravel but on investigating the develop branch, when I create a new package with workbench, files are still organized in the PSR0 structure and it seems that the dev is still expected to use the src/controller/ dir for controllers by adding the dir to the composer classmap. Ideally, package structures in 4.3 that are created from workbench would be similar to the one found in app/ which uses a PSR4 structure.

My bad if this task or similar was already created.

Implementation

  • Review implications. Since I'm new to laravel this may be a bit but there may not be much different from the rest of 4.3. Some of you may be able to help.

  • Edit file structure that is created. This is a matter of changing the structure that's created in Workbench/PackageCreator. The locations are below (relative to package root).

    • config - config/
    • controllers - src/Http/Controllers/ (assuming people are ok with controllers being a part of packages by default)
    • lang - resources/lang/
    • migration - database/migration
    • views - resources/views/
    • [service provider] - src/VendorPackageServiceProvider.php (remember it will be psr4)

    All other directories stay in the same location from what I can tell.

  • Edit the composer stub and...

    • Make PSR0 part be PSR4 which will be the user's Vendor\Package\ name mapping to src/ (do the stubs accept variable replacement?)
    • Change classmap portion to just map the database/ dir similarly to app.

Any info would be appreciated. Also, I'm new to this community so forgive me if I missed anything.

@ibrasho
Copy link
Contributor

ibrasho commented Sep 3, 2014

I support this.

@johnpancoast
Copy link
Author

Once a proposal is approved, a pull request may be created implementing the new feature.

I support this.

Is this that approval? Not sure who approves.

@jasonlewis
Copy link
Contributor

Taylor does.
On 4 Sep 2014 07:22, "shideon" notifications@github.com wrote:

Once a proposal is approved, a pull request may be created implementing
the new feature.

I support this.

Is this that approval? Not sure who approves.


Reply to this email directly or view it on GitHub
#5643 (comment).

@barryvdh
Copy link
Contributor

barryvdh commented Sep 4, 2014

I think this isn't so easily done because some locations are hardcoded (like public, views, lang and config). You could just use PSR-4 and make it something like this:

 - public
 - src/
    - config
    - lang
    - migrations
    - views
 - tests

And still load /src folder with PSR-4, but that would mix classes with other resources.

But it would be nice of packages could be structured more similar to the new laravel folder. But that would mean something has to change to allow for flexible paths, see #4118 for example.

@johnpancoast
Copy link
Author

but that would mix classes with other resources.

Exactly. Thanks for the link to the other proposal. I'll see what @anlutro did.

If paths are hardcoded to src/whatever/, would it work to just change what they're hardcoded to for the sake of this task and getting workbench packages to psr-4? Then allow customizable paths later in #4118 if someone decides to address that there? I could be missing details.

@barryvdh
Copy link
Contributor

barryvdh commented Sep 4, 2014

No they are hardcoded so you can do php artisan config:publish etc. Changing the paths will break all existing packages. The best option would be to make it configurable first and then allow packages to set their own paths. But this would only be possible on the version this would be implemented in (so probably 4.3) and would thus not work on on older versions of Laravel..

@johnpancoast
Copy link
Author

Makes sense. I'll look into the proposal you mentioned.

@GrahamCampbell
Copy link
Member

Replaced by #5807.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants