Welcome Guest, Not a member yet? Register   Sign In
Use the helpers and libraries without MVC flow
#1

[eluser]Unknown[/eluser]
Hello,
my question is particular.

I would create an web page in Codeigniter root (where there is index.php).
This web page should use helpers and libraries of Codeigniter.

I try to create "prova.php" and I insert in this page: $CI =& get_instance();
but, naturally:
Fatal error: Call to undefined function get_instance() in C:\Dati\amcms\prova.php on line 11

Thank you! Smile

Bye
Maverick5
#2

[eluser]TheBaron[/eluser]
Why aren't you using MVC and creating a Controller? Then setting that controller as the default controller?

You can't use get_instance() without bootstrapping CI. If you are going to go through the hassle to do that you might as well use CI..
#3

[eluser]Unknown[/eluser]
I would create a web site with 2 parts: a back-end part with MVC structure of CodeIgniter and a front-end part without MVC structure but it can use libraries and helpers of CI. The front-end part are the web pages in the root of CI (whois.php, whereis.php, etc.)

Is possibile the bootstraping of CI by the root?

Thanks
#4

[eluser]TheBaron[/eluser]
I still don't understand you want to do this?

Why don't you just set up your project like this?

Quote:/controllers
--/admin
----/users.php
----/pages.php
--/whois.php
--/whereis.php

You would the have the following urls.

root.com/admin/users
root.com/admin/pages
root.com/whois
root.com/whereis

If you need to use CI in your frontend then use CI. Hacking something together is bad practice without a valid reason.
#5

[eluser]danmontgomery[/eluser]
Helpers are just files with functions in them, and libraries are just classes which generally don't have any CI specific code.

Code:
include('application/helpers/some_helper.php');
some_helper_function();

include_once('application/libraries/some_library.php');
$library = new Some_library();
$library->some_method();




Theme © iAndrew 2016 - Forum software by © MyBB