Closed dcblogdev closed 8 years ago
Thanks Dave. This is a good change. Personally, I think it's should be 3.0, since the core structure is changing and further functionality will be based off of this new structure.
Yeah @volter9 said the same thing for 3.0 it does make sense. The only issue I need to solve now is getting modules css to work in the public when placed above it.
It's been suggested have 2 module folders 1 - above the root containing the module classes etc 2 - mobiles folder in the root for it's css/js files
I'd rather have a single place for the module so it's standalong and plug and play so to speak.
@daveismyname I also think version 3.0 describes it best. According semver.org you change a lot of things:
Given a version number MAJOR.MINOR.PATCH, increment the:
MAJOR version when you make incompatible API changes
And with your changes you break the backward compatibility.
I wonder how this will effect ftping to shared servers? I currently use git ftp which pushes my whole folders changes to the server. Perhaps this would mean that I would have to store a public_html folder in my git repo? Thoughts?
I think you would have the public_html folder in your structure, that's what I have typically.
https://www.dropbox.com/s/hfbl0dzcem82ob6/Screenshot%202015-11-29%2011.04.04.png
I cant see that link but your comment answers my question :+1:
Why Vendor in the app? Personally, I would prefer like this (personal vision :)
app
Controllers
Core
Helpers
Language
logs
error.log
Models
Modules
views
templates
public
assets
templates
default
css
js
modules
some_name
css
js
.htaccess
index.php
vendor
.gitignore
composer.json
licence.txt
Obviously should be version 3.0
It's going to be 3.0
I'm happy with that structure only question why is there a templates folder in views?
Everything looks solid, and will definitely make the framework better
By mistake, it should be in the app :)
I have a question about Models Currently, we use model like this:
$this->blog = new \Models\Blog();
$data['posts'] = $this->blog->getPosts();
Is it possible to be this way?
use Moldes\Blog;
$data['posts'] = Blog::getPosts();
? :)
Maybe a good idea to rethink the models too. And maybe make an extra service layer for business logic. And maybe also let the models be the actual models (classes with database data mapping) so you could use PDO FETCH CLASS to let the record data map into the models. (Database fetch logic in service classes).
@mickacz The only issue I see with that is then there is no difference between the way we use helpers and the way we use Models?
What @mickacz is about mentioned, shouldn't we avoid too much public static? I read it somewhere saying its bad design?
@mickacz I don't think it is with the models extending the base model
Dear Dave,
I think this new structure will be an issue for me. My serveur is used to serve multiple apps based on smvcf.
Today, everything is fine, I have one directory per smvc. www/ smvcf1/ smvcf2/ ...
Then I access my apps : http://mysite/smvcf1/ http://mysite/smvcf1/ ...
Moving to the new architecture, how this will look like ??? How can I differentiate the multiple app/ dirs if they all go beneath www/ ?
Please advise. Laurent
PS / I do not have a security issue having all the files in one public dir. This is how it is done for common CMS (Joomla, Wordpress). Files are anyway not directly accessible.
@yeshelolo you can put them all in one place still in the index.php file is a variable for the path to the app folder that would just be ./ instead of a ../ that way it can all reside inside the public folder as you do normally.
@tomvlk I'm interested in what you're suggesting, but not sure I follow 100% could you explain a little more on your idea?
@daveismyname the service layer is a bit explained here: http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/oop-terminology-part-viii-service-layer-156 In the model you define your variables that your database entry has. In the service class you define the CRUD operations for the model and with optional more methods for getting with specific id's and stuff like that. So your SQL will be executed from the service layer.
Another good graph that explains: http://i.stack.imgur.com/hlhOw.png
@tomvlk thanks I'll have a read of them later.
@tomvlk We use a service layer at work, but that is sans-framework. Im not exactly sure that a service layer is the right idea for a simple Framework such as SMVC. But definitely interested to see how you would go about implementing it. Sounds like something that could work really well.
I've already used it in combination with PDO_CLASS fetch and simplemvc. You only have to make lazy getters for associations. But thats really not that much work if you let the service classes extend one abstract service class with most of the logic.
Actually I've always wondered why frameworks have almost the same default structure, like codeigniter, For me, an application(implementation) has models, controller and views, so maybe they should be inside the app folder , the rest of the files like helpers, core, etc... should be on their respective folder. I think separating the framework from the implementation is the logical step to do. I would like to hear your thoughts.
app
Controllers
Models
Views
system
Core
Helpers
Language
logs
error.log
Modules
vendor
composer.json
public_html
templates
default
.gitignore
.htaccess
index.php
licence.txt
I like it, but just a detail, I supose you use public_html name because is the default web folder in some web servers, but I think that nowadays _html suffix is incongruent, maybe public is enough.
Is only a detail, but public_html is longer than public and really this folder will contain other files as css, images, js...
By other hand I'm agree with geomorillo with separate system files from app files. Is interesting for framework updates and to share the system folder between projects.
@daveismyname on my host I will still need to be under the public_html folder, how do I structure it.
@jimgwhit you can put them all in one place still in the index.php file is a variable for the path to the app folder that would just be ./ instead of a ../ that way it can all reside inside the public folder as you do normally.
@geomorillo that structure looks fine but I would have Modules inside the app also have another modules folder inside public for the module specific css / js files
@rtorralba the public_html folder is dependent on your setup some will be public_html some will be htdocs some may be something else it should not make any difference. Lets call is public then it can be changed as needed on implementation.
Any objections to a app / system setup? seems logical.
The final result will be flexible enough so you can place all files inside your public directory should you need that.
@daveismyname also this
public_html // /is this the hosting servers folder where things go?
templates
default
.gitignore
.htaccess
index.php
licence.txt
Would keep you from having more than one site I could see
public_html
public1 // could be site 1
templates
default
.gitignore
.htaccess
index.php
licence.txt
public2 // could be site 2
templates
default
.gitignore
.htaccess
index.php
licence.txt
You are saying to put files directly in what is the htdocs folder on some host.
htdocs // this this the hosting servers folder where things go? where would templates for site 2 go?
templates
default
.gitignore
.htaccess
index.php
licence.txt
Very confusing.
Also please give instructions on how to still put the framework under htdocs, My host still requires that. The tricky part to me is getting paths right.
On godaddy I have:
public_html (this is like www, or htdocs folder where host says put your site)
mysite
app
public
vendor
index.php
other files
In other words the standard way you normally upload to host. Just please tell me how to still do this with new version, and how those paths would be resolved.
We need to agree on the structure before that can happen. Once that's agreed of course it will be documented I would not leave out such an important step.
What I'm saying is you will be able to have a project folder in your public folder (public_html / htdocs / public / whatever) then place the folders within that such as app / system and the root files.
Then for the people that want to place the app / syste, files above the document root that will be supported too.
I would like to test on godaddy, do you have a zip to send to kpsklab@yahoo.com I just get very confused on resolving paths. Look at my godaddy structure above, pretty standard for a shared host. I would probably need
newsmvc // folder above public_html
folders and files you said goes above
public_html
smvcpublic
public
files you said goes in public
I can't just put public under public_html, I have 2 sites. I can't have 2 folders named public, what am I missing. For diagram above what would RewriteBase /newsmvc/ be changed to? I can't see it being RewriteBase /public_html/smvcpublic/public/
An idea, can you completely set up all on a hosted server like godaddy, get it working, then zip it and make a copy available for download, so everyone would see how all the new paths resolve. I have spend 5 hours before getting paths right, it's not fun.
@jimgwhit yes happy to, I'll model this on the structure proposed above.
Of course I am referring to the Ver 3 when released.
I like @geomorillo's way of doing it, keeping the app and system files separate.
yeah just got ensure the paths work will require a little tweaking here and there and looking at getting composer to autoload from both directories.
@daveismyname I made an important observation, Even laravel installs with composer under (htdocs, www) on a local development machine. It's not till you upload it to production server that they say to put stuff a level above htdocs. This being the case, how will the new version work on my development server? I wouldn't have any idea how to separate stuff out. I currently use a bitnami wamp stack. And all development falls under the htdocs folder.
Sorry if this is getting confusing, but please think about maybe having the framework for development still under htdocs, with instructions on how to separate once uploading to a production server / host. I'm not advocating laravel here, but that's the way they do it, give it a try yourself for testing purposes.
http://laravel.com/docs/5.1#installation
In other words, if you upload via ftp laravel works as is, you only have to modify / resolve paths if you are moving the main stuff up a folder.
for local setup all you do is place your files in your project folder like this:
app
Controllers
Models
Views
system
Core
Helpers
Language
logs
error.log
Modules
vendor
composer.json
templates
default
.gitignore
.htaccess
index.php
licence.txt
inside index.php the $smvc var will be simply:
$smvc = './';
then on production server it's:
app
Controllers
Models
Views
system
Core
Helpers
Language
logs
error.log
Modules
vendor
composer.json
public_html
templates
default
.gitignore
.htaccess
index.php
licence.txt
and
$smvc = '../';
@daveismyname
app
Controllers
Models
Views
system
Core
Helpers
Language
logs
error.log
Modules
vendor
composer.json
public_html
templates
default
.gitignore
.htaccess
index.php
licence.txt
How would or could this work if you had 2 sites, that folder structure would force putting template files from more than one site together. You need another folder. Like:
public_html (www or htdocs on some)
site1
templates
default
. gitignore
. htaccess
index.php
licence.txt
site 2
templates
default
. gitignore
. htaccess
index.php
licence.txt
same with this
app
Controllers
Models
Views
system
Core
Helpers
Language
logs
error.log
Modules
vendor
composer.json
it would need to be
upperlevelfolder1 (site 1)
app
Controllers
Models
Views
system
Core
Helpers
Language
logs
error.log
Modules
vendor
composer.json
upperlevelfolder2 (site 2)
app
Controllers
Models
Views
system
Core
Helpers
Language
logs
error.log
Modules
vendor
composer.json
Otherwise you have files from 2 or more sites combined in the same folder.
And this is where resolving paths can get hard to do.
yes for multiple projects you would place each in a separate folder, to use different folder names that can be accomplished. The finer details on that I'm testing still.
I am wondering how this will effect git ftp push. I use git for my websites and use git ftp push for moving my changes live. This works really well because everything is in the same folder and git is based in that folder. and I can push it to a folder on the server.
How do others manage their ftping?
I still ftp with plain old ftp so I can't answer that at least not yet.
Yea OK I could do plain old ftp but git ftp is really nice it picks up your commits and only pushes those files! that way you dont have to remember what you have changed and also it excludes files in your gitignore (like config!)
@daveismyname please email me a zip file so I can start testing or post a link here for us to download Thanks.
I have to build this first I'm working on it.
I meant when you had something ready, thanks.
Nearly ready, I have the framework in the new structure working on the root of a domain and also 2 more installs in demo1 and demo2 all system/app files above the document root.
Need to do more testing but looks all OK so far.
demo1 and demo2 are distinct projects and public_html/demo1 and public_html/demo2 public files for this projects?
yes the demo 1 and 2 above the publc_html contain a app and system folder for the project.
Inside public_html is the templates and index.php .htaccess files
This is your proposal for the standard structure or is a specific example?
for the proposed structure with an example of using multiple projects on a single domain, normally you would have a single project per domain.
This structure is based from https://github.com/simple-mvc-framework/framework/issues/222#issuecomment-161145544
Then how you put the projects in a git repository (app and public folders are in different folders)? I supose that is a project with multiple smvc instances, no?
For the sake of a repo can you have a generic public folder for the templates and front end files and the app and system folder outside the public folder?
I've given the framework a bit of a restructure so it main files are outside of the web root by default and the only files that should be inside the web root are the templates, .htaccess and index.php.
so the structure is now like this:
From the index.php the starting path would be:
The vendor path would be
I've also adjusted the view class and url helper to make the paths more flexible.
This would mean all public files (templates) would be in the web root all classes would be outside the web root.
The logger class has been changes since it would no longer be able to serve html errors they would be stored in app/logs/error.log above the document root.
This kind of setup needs to happen, it's a basic security practice. I'm very late in changing this.
First off is there any objections to this?
Additionally should this be a sub part update 2.2.1 or warrant a full version increase? personally I think 2.2.1 would be sufficient no new functionality has been added.
Another area I'm not 100% on is Modules. They may need to be in the web root as well so any modules containing css can be loaded but at the same time they will contain classes so should be above the root! will require some thought on this one.
I haven't pushed this up yet I'm waiting to get your thoughts on this.