CodeIgniter Forums

Full Version: Accessing CI methods from external script? (CI v2)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have an external script (sat in the root folder, alongside CI's index.php) that ideally I need to access CI's methods e.g. models.

I found this article, but its outdated.

I even tried the answer here, but that didn't work.

So, is there a way to achieve this?

(I fully understand it may not be secure or best practice, I'd just like to know if it's possible, and how to do it)
Why not create a controller that does the job and access it with CLI?
Because I am not able to access the CLI. I specifically need to do it this way.
@mr_pablo

https://github.com/ivantcholakov/starter...c/demo.php
http://iridadesign.com/starter-public-ed...c/demo.php

See how this page works. If it is what you need, download the whole project. I have no a quick separate solution.
(03-18-2015, 04:00 AM)ivantcholakov Wrote: [ -> ]@mr_pablo

https://github.com/ivantcholakov/starter...c/demo.php
http://iridadesign.com/starter-public-ed...c/demo.php

See how this page works. If it is what you need, download the whole project. I have no a quick separate solution.

This looks like it may help.

Can I use this alongside my CI v2 app without issues?
You may try to migrate the application. I still support the older CI2 class/file naming convention, probably most of your code will work without modifications. But check the CI2 -> CI3 migration notes: http://www.codeigniter.com/userguide3/in...e_300.html
(03-18-2015, 04:21 AM)ivantcholakov Wrote: [ -> ]You may try to migrate the application. I still support the older CI2 class/file naming convention, probably most of your code will work without modifications. But check the CI2 -> CI3 migration notes: http://www.codeigniter.com/userguide3/in...e_300.html

So I shojuld put the "platform" directory alongside my current CI application?

Or is there a way to use my current CI application with the additional parts you have made? As I can see you include a CI installation inside your "platform" directory, but I don't really want another CI app, when I already have the files for one.
You can move directories, I don't have documentation about it. Just trace code starting from index.php and you will figure out how to rearrange directories as you wish. See this file for example: https://github.com/ivantcholakov/starter...config.php

Edit: I checked, actually within README.md, in the Installation section there are some words about $PLATFORMPATH.
If you want, you may "merge" the folders www/ and platform/ into one folder that would be your web-server root folder, but I don't recommend that, the installation would be less secure.

Edit 2: For further questions open an issue on the project's page for not polluting the forum here with irrelevant stuff.