laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.42k stars 10.99k forks source link

Namespaced Structure #5419

Closed hernandev closed 10 years ago

hernandev commented 10 years ago

Hi, i know is kinda too early to discuss what @taylorotwell is doing on the laravel/laravel repo for 4.3, as it is right now, app/src/app is holding a "Model" and There are some new folders holding Http (Controllers and Filters) and another one holding Providers

app folder is namespaced under "App" namespace and the providers under the "Providers" one.

Would not great put it all under the same easily changeable root namespace?

App\Providers App\Http\Controllers App\Http\Filters App\Http\Requests (not entirely right what's this one about yet) App\Providers App\Models or App\Data ou App\App (whatever)

This will make it really easy to make any app modularized, since you can put different stuff inside the same project into different namespaces, and them only register them.

This is not a new thing, it's a little like Symfony Bundles. This is almost the same thing i already do manually when creating a Laravel project.

This could even be a future skeleton for package development, since it's enough modularized for me.

Another good point is having an artisan command for generating this skeleton, to force people not using always the "default" one.

I'm not really sure if it will really works great as it's in my mind right now, help if you opinion about that.

Thanks in advance.

Anahkiasen commented 10 years ago

Yeah I'd prefer if it was all under the same namespace too.

fhferreira commented 10 years ago

+1

GrahamCampbell commented 10 years ago

Also, :+1: for psr-4 being the default autoloading in laravel 4.3.

Anahkiasen commented 10 years ago

Also, :+1: for psr-4 being the default autoloading in laravel 4.3.

This. I'm aware the autoloaders that allow you to load classes without namespaces (like it did for models and controllers in 4.2) are cool but while it should remain a possibility I think the default should just be to delegate all autoloading to Composer for best practice.

GrahamCampbell commented 10 years ago

Yeh.

hernandev commented 10 years ago

Also, :+1: for psr-4 being the default autoloading in laravel 4.3.

This. I'm aware the autoloaders that allow you to load classes without namespaces (like it did for models and controllers in 4.2) are cool but while it should remain a possibility I think the default should just be to delegate all autoloading to Composer for best practice.

Migrations are the most special case i can think of, do you think making a provider to expose them inside an namespace is the right choice or do you have another ideia for it?

Anahkiasen commented 10 years ago

No migrations aren't really classes to me, and you can't make them follow PSR because their names is timestamped

hernandev commented 10 years ago

Yeah. agreed with that, but i do think adding something like

php artisan migrate --namespace="App\Migrations"

or

php artisan migrate --source="app/src/whatever/folder/having/a/migrations/subfolder"

following the same logic that --bench and --package will allow better code organization.

Btw, with or without this, following the proposal will drastically decrease the composer classmap section.