Closed dcblogdev closed 8 years ago
Why not make it with the following structure, protecting non public folders, if are a different projects?
I supose there ara a restriction that i didn't read
the index.php needs to be within public_html the app and system folder are like this in my new setup.
In side the public folder will be:
templates
index.php
.htaccess
my screenshot had multiple folders only to show how it could work with multiple projects on the same domain.
When using a single domain and a single install it would simply be
@daveismyname Okay but what is the folder structure when everything will still fall under HTDOCS or www or public_html depending on shared hostt? Like some shared host will still require? Please give a good example of this also and how to resolve paths.
Also example htaccess and config.php examples please for various setups.
@daveismyname did you look at laravel like I asked you to there you only go above wwww / htdocs in production not in development. So definitely need examples for the various situations.
@daveismyname And how in the world will composer install this? On development machine there is no way that folder structure works , on development everything has to go underneath htdocs.
@daveismyname Okay but what is the folder structure when everything will still fall under HTDOCS or www or public_html depending on shared hostt? Like some shared host will still require? Please give a good example of this also and how to resolve paths.
Also example htaccess and config.php examples please for various setups.
I've posted examples above, with 3.0 the paths are flexible that can be defined within index.php so you can move them as desired.
For instance to have the app and system folder above the docroot in a folder called myproject you would have this in index.php:
$smvc = '../myproject/app/';
$system = '../myproject/system/';
to have app and system inside your public root then its
$smvc = 'app/';
$system = 'system/';
it's flexible.
Both config and .htaccess remain unchanged the paths in those are relative to the url / for the root and /projectfolder/ for when inside a folder.
@daveismyname did you look at laravel like I asked you to there you only go above wwww / htdocs in production not in development. So definitely need examples for the various situations.
You should give more thought to your wording that sounds like you're giving me an order. I don't work for you, I give my time freely for this project please be respectful.
This has been addressed above.
@daveismyname And how in the world will composer install this? On development machine there is no way that folder structure works , on development everything has to go underneath htdocs.
the same way as you do now. All composer is doing is downloading the files. There has always been an element of configuration needed 3.0 will be no different, the htaccess and config file will need setting up along with htaccess.
I have this working both on a local server under php 7 and on a live server under php 5.6 so it is indeed working.
Honestly I'm not going to leave users stranded with a version that does not work. I have projects both on a dedicated server and on a shared server so I understand the need for both cases.
@daveismyname You have to know I didn't mean any dis-respect, I meant to maybe get ideas form laravel, yii, etc. You have been very good at resolving problems in the past.
I apologies if I came across as angry it's been a long day let's not say anymore on it.
I'm 90% sure this new structure is good to go I'm going to do more tests and tryout an average project before I do a beta release of this for wider testing.
Really good job you are doing dave, please rest a bit dont overwork, is bad for health cheers
thanks I appreciate the support :)
Are you going to create a new branch on github for this new version?
I was going to release it as a new release, to be honest I don't use github enough. I don't know about branches I'll be sure you look at them.
A beta first is a great idea. Please give a link here in this issue #222 when you have it. But like @geomorillo said rest some, no hurry. I'm sure all of us realize you need to test first.
I think it should be:
app
system
public
vendor
.gitignore
composer.json
licence.txt
Otherwise it will not make sense
Look at the structure of mako-framework, various skeletons of Slim 2-3, Laravel. None of them holds inside public .gitignore or vendor from composer inside system.
I dont see why the framework has to follow those structures, could you explain why they should be outside? maybe im not getting something.
I don't think they NEED to be but after a few tests I actually like it that way. From a paths perspective it makes it a lot easier.
With the dynamic paths it's still easy to change should to want to it's got a :+1: from me.
Any way we can get a zip of what you go so far for testing?
Yeah I'll do a bit of cleanup and get something up in a few hours.
great, already on the beta branch
OK I've got a 3.0-beta branch setup with 3.0 for testing purposes only this should not be considered as stable.
I've created a temp readme file detailing the major changes and how to get up and running with it. I stress again this is very early stage beta testing please bear that in mind.
https://github.com/simple-mvc-framework/framework/tree/3.0-beta
@daveismyname what would $root = '../'; be change to if all is going under public_html?
./ should do it.
So
$smvc = '../app/';
$system = '../system/';
$root = '../';
To
$smvc = 'app/';
$system = 'system/';
$root = './';
How about the error log, how can it stay under public_html?
Yes
It's inside of system folder so it will be in your case.
I made this route
Router::any('home', 'App\Controllers\Welcome@index');
tryed
$smvc = 'app/';
$system = 'system/';
$root = './';
then tryed
$smvc = './app/';
$system = './system/';
$root = './';
url I tryed
http://localhost/fm3/home
both trys above I get
Not Found
The requested URL /fm3/home was not found on this server.
I will keep trying to resolve the paths any tips?
Have you got /fm3/ in your config.php file and .htaccess?
yes
define('DIR', '/fm3/');
and
RewriteBase /fm3/
This is how I have always done it before. These aren't being resolved right probably
$smvc = 'app/';
$system = 'system/';
$root = './';
I even tried ../, ./, ../../ various combinations. Will the new technique work if I put fm3 right in apache2 and not htdocs?
I can't do that on host.
Re tryed all these
$smvc = '../app/';
$system = '../system/';
$root = '../';
$smvc = './app/';
$system = './system/';
$root = './';
$smvc = '/app/';
$system = '/system/';
$root = '/';
$smvc = 'app/';
$system = 'system/';
$root = '';
$smvc = 'app/';
$system = 'system/';
$root = './';
$smvc = '../fm3/app/';
$system = '../fm3/system/';
$root = '../fm3/';
@jimgwhit I think you should try with:
define('DIR', '/fm3/public/'); RewriteBase /fm3/public/
http://localhost/fm3/public/home
As index.php file is now located in 'public' folder.
I got it, Insructions say
for a localserver place the files within public in the root of your project (move them up a directory so they are with app and system)
I didn't know I was to move templates, I finally got welcome page. this is what worked
$smvc = 'app/';
$system = 'system/';
$root = './';
Ok I will continue on to more test, that's -- still confused on error log.
I figured out the namespace for models is namespace App\Models; But so far I did quick test and I am getting database results. @daveismyname keep us posted. Sorry about the template thing, I moved it up even with other folders, was that correct?
Yes that's correct to have them working in the same folder under the public root or when on a localserver.
For the errorlog to see errors you can either go to the log directly in system/logs/error.log or go to system/Core/Logger.php and turn display to true. That will print errors to the screen when they happen, they will be to recorded in the error.log
a quick video going over the major changes and getting setup https://www.youtube.com/watch?v=28l8lJz-oRM
:thumbsup:
Got it working on development With all under htdocs.
Then tryed the move it up thing here is folder structure:
C:\Bitnami\wampstack-7.0.0-0\apache2
......................................tjupfold
..............................................app
..............................................system
..............................................vendor
Folder structure for other files:
C:\Bitnami\wampstack-7.0.0-0\apache2\htdocs\tjtest
..................................................public
..................................................the other files
In config.php I tryed
define('DIR', '/tjtest/public/');
and
define('DIR', '/tjtest/');
in htaccess I tryed
RewriteBase /tjtest/public/
and
RewriteBase /tjtest/
In index.php I tryed
$smvc = '../tjupfold/app/';
$system = '../tjupfold/system/';
$root = '../tjupfold/';
// with this I get the message
Please install via composer.json
Install Composer instructions: https://getcomposer.org/doc/00-intro.md#globally
Once composer is installed navigate to the working directory in your terminal/command promt and enter 'composer install'
and tryed
$smvc = '../../tjupfold/app/';
$system = '../../tjupfold/system/';
$root = '../../tjupfold/';
If I run composer with above folder structure, It won't install correctly.
Any help here?
i cannot understand your folder structure specify your url and a clear folder structure.
That's the structure that is actually on the computer, url should be
http://localhost/tjtest
The 3 folders you said to move is now under apache2\tjupfold like
apache2
............htdocs
........................tjtest
...............................public
............tjupfold
.........................app
.........................system
.........................vendor
..........,,
I'm trying the move it out of htdocs on local developer machine.
if tjtest is your project what is tjupfold?
If you running this locally you don't need public at all remove it completely. You structure looks like you have tjupfold inside public then have app,system,vendor under that.
No tjupfold is above htdocs.
You have apache2\htdocs where sites normally go.
I tryed to create the folder tjupfold under apache2 so the 3 folders would be out of htdocs.
tjupfold is not under htdocs.
Your first image above with demo is what I'm trying. Does the upper folder name have to be same as the folder name that is in htdocs?
ah you've update you post it was like this when I read it:
apache2
htdocs
.............tjtest
.............public
..............tjupfold
.........................app
.........................system
.........................vendor
..........,,
right in this case you still don't need public so delete it have your templates / index etc inside tjtest
then
$smvc = '../../tjupfold/app/';
$system = '../../tjupfold/system/';
$root = '../../tjupfold/';
Will give it a try, meanwhile can (when you get a chance) do a video on the move it up thing?
Sure.
Holy freaking mackerial that worked.
So is this correct. Set it up on local for development like in video you did, then do the above last reply for production?
yes exactly, you can have it all together for development then in production more the folder above the root
And of course is a host doesn't allow the up thing, it would still work as usual.
yes I still need to test across different cases just to make sure but I'm fairly certain it's flexible enough to cope.
Oh I had to change in Url
public static function templatePath($custom = TEMPLATE)
{
return DIR.'templates/'.$custom.'/';
}
to
public static function templatePath($custom = false)
{
return DIR . 'templates/';
//return DIR.'templates/'.$custom.'/';
}
and in header I do
<link href="<?php echo Helpers\Url::templatePath(); ?>default/css/style.css" rel="stylesheet">
Was getting two // after templates.
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.