Post by Qphoria » Tue Mar 23, 2010 1:55 am

I've noticed that the index.php and admin/index.php files have been growing into a huge pile of code, most of which is common between the two. I also see the "startup.php" file which seems to handle similar bits of code.

Why not just move all the common stuff into startup.php or something like common.php. This can cut down on the redundancy. It would also help make external 3rd party scripts that don't use the controller to easily include the common file for easy integration.

Examples
index.php has:

Code: Select all

require_once(DIR_SYSTEM . 'library/currency.php');
admin/index.php also has:

Code: Select all

require_once(DIR_SYSTEM . 'library/currency.php');
system/startup.php has:

Code: Select all

// Common
require_once(DIR_SYSTEM . 'library/cache.php');
require_once(DIR_SYSTEM . 'library/config.php');
require_once(DIR_SYSTEM . 'library/db.php');
require_once(DIR_SYSTEM . 'library/document.php');
require_once(DIR_SYSTEM . 'library/image.php');
require_once(DIR_SYSTEM . 'library/language.php');
require_once(DIR_SYSTEM . 'library/log.php');
require_once(DIR_SYSTEM . 'library/mail.php');
require_once(DIR_SYSTEM . 'library/pagination.php');
require_once(DIR_SYSTEM . 'library/request.php');
require_once(DIR_SYSTEM . 'library/response.php');
require_once(DIR_SYSTEM . 'library/session.php');
require_once(DIR_SYSTEM . 'library/template.php');
So the currency require step could certainly be done in the startup.php

Same thing with all the rest of the registry stuff:

Code: Select all

// Registry
$registry = new Registry();

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// Config
$config = new Config();
$registry->set('config', $config);

// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
It's all the same in both files and should be in a common place. Only the specifics should be in the individual index files

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Daniel » Tue Mar 23, 2010 2:00 am

i set currency class to be loaded in the inedx.php because its it not a class that will be used building any php web site. its more application specific.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by Qphoria » Tue Mar 23, 2010 2:32 am

I guess from a "framework" point of view that is true. Though I'm not so sure. Anyone formatting a price could use it. What about the other registry setups for config, db, etc.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by maze » Wed Apr 14, 2010 11:42 pm

When working over opencart script (i mean when editing, developing); do you offer any framework? if yes which one?

Newbie

Posts

Joined
Wed Apr 14, 2010 6:23 pm

Post by Qphoria » Thu Apr 15, 2010 12:11 am


Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by maze » Thu Apr 15, 2010 4:42 pm

i open those pages for reading, Thanks Qphoria

Newbie

Posts

Joined
Wed Apr 14, 2010 6:23 pm

Post by migz » Thu Apr 15, 2010 8:02 pm

I think that's ok because /admin and /store are separated. its great because i can put admin anywhere i want.

Active Member

Posts

Joined
Mon Feb 01, 2010 2:13 am
Who is online

Users browsing this forum: No registered users and 8 guests