CodeIgniter input class outside codeigniter - codeigniter

I'm moving an app from flat file php to codeigniter and I'd like to integrate the two as much as possible before moving over completely. I'm looking to specifically use the input class outside of codeigniter but it looks like I'd also need to use the controller logic (to get access to input segments). Can anyone walk me through using the input library in a flat file php?

I think you're creating too much work and potential problems by trying to do this. You'll be better off if you go directly to CI. Move any standalone functions in your standard PHP files into Helper functions.
If you really want to do this, you could use CI and create controllers/functions for all your files, then in the controller functions, just include() your PHP file and ignore the models and view for now. That way you'll have access to all the CI variables, including the $this->input data.

Related

Learning Laravel blade standalone

I'm pretty new with blade template building in Laravel and I'm planning to use it as standalone. What's the best way to learn blade template building perhaps for standalone?
What's the different components of blade template building and what's the data flow?
If you want to use without Laravel, then you could try my library.
https://github.com/EFTEC/BladeOne
Its stand alone, only one class and no dependencies (and mit license)
The docs about blade is here
https://laravel.com/docs/5.5/blade
The data flow is simple:
add all the libraries and dependencies.
creates all the
variables, collects information from $_POST,$_GET and such.
Load
and do all the operations, such as loading from the database,
inserting, doing some operation.
And finally, call the template and send the variables. The template must be called at the end of your script. Always.

Using Code Igniter active record in Wordpress

Need to move some code from Code Igniter to Wordpress. It is heavily using CodeIgniter's db classes to handle the database. I would like to use them like this, instead of translating to WP's wpdb.
Is there any way of using Code Igniter active record/db classes and keep the nice CI db usage in Wordpress?
Thanks
If you are using WordPress 3.3 and above, then you can make use of the following library WordPressIgniter
Usually, it's not as straight forward as you think, because both of them have their own code structure. But many have tried it and are successful. It depends on what features you want to use and to what depth.
Following links may come handy for you:
SO - CI WodrePress Integration
http://www.marketingadept.com/blog/integrating-codeigniter-and-wordpress/

use boilerplatejs with codeigniter

What is the best way to use codeIgniter with BoilerplateJS? should I put the codeIgniter folder in a BoilerplateJS folder or the contrary? Or something else? Need to make an authentifcation page in codeigniter and redirect the application in boilerplateJS.
Thanks.
I tried BoilerplateJS with CI in the following way:
Basically this is including BoilerplateJS in CodeIgniter folder.
I included all the BoilerplateJS code except the index file in to a folder named public which is in the root folder of CodeIgniter. The index file is placed in the views folder and will be loaded by a controller. (See the image)
For this to work some file paths had to be tweaked.
File paths in boilerplatejs index file (boilerplate.html in my case) had to be changed as follows:
./libs/jquery/jquery-min.js >>to>> public/libs/jquery/jquery-min.js
./libs/underscore/underscore-1.3.3.js >>to>> public/libs/underscore/underscore-1.3.3.js
and so on.
In main.js requirejs path configurations should be changed to:
require.config({
//Let's define short alias for commonly used AMD libraries and name-spaces.
paths : {
// requirejs plugins in use
text : 'libs/require/text',
i18n : 'libs/require/i18n',
path : 'libs/require/path',
// namespace that aggregate core classes that are in frequent use
Boiler : './app/core/_boiler_'
}
});
And in your controller you can load boilerplatejs by: $this->load->view('boilerplate.html');
I was thinking of integrating BoilerplateJS and CodeIgniter and probably use codeignighter-rest server for some time.
If all goes well I will share the code within the week.
A sample project is available at: https://github.com/slayerjay/codeigniter-boilerplatejs
EDIT Adding my view on CodeIgniter and BoilerplateJS
Firstly I have not (yet) done any major projects with BoilerplateJS and Codeigniter. But I have done projects using CI and the CI REST Server and know BoilerplateJS in and out.
I do not have much experience with other PHP frameworks (I have meddled with cakePHP and some others) but for me CI helps me to organize my code according to MVC pattern in a clean way, and provides excellent helper libraries and documentation.
As the OP rightly said, authentication is handled best outside BoilerplateJS and this can be done nicely with something like ion-auth for CI. After the user is authenticated and the SPA is loaded, the rest of the calls will be handled by the CodeIgniter REST server.
In this case you won’t be using much of the View aspect of your MVC architecture, but CI’s models and helpers would be of great help.
If you just need a simple REST server you can go with some lightweight solution that just provides REST type routing, but in many cases you will need to interact with a database and do some data processing.
So if you have decided to have a PHP backend for your application, Codeigniter with the REST server is a good choice.

Codeigniter loading a helper without the "_helper" suffix?

I am trying to implement a OrientDB HTTP connection in Code Igniter, but I can't quite decide how to go about it. Basically, I am using the php code found here, and I cannot decide whether to make that file collection into a library or a helper.
Right now, I am leaning towards a helper, because $this->load->library() automatically instantiates the class, where I will need the ability to call static methods as well (as can be seen in the use of BindingParameters::create('http://admin:admin#127.0.0.1:2480/demo');) in the example code.
So, if I make these files into helpers, which should not instantiate the classes, is there a way to load them without adding a "_helper" suffix to the files themselves? I would like to avoid using require/include, but if there is no other way to accomplish this then I have no choice.
Does anyone have any tips or ideas that may help me with this? Thanks beforehand.

How to manage URLs in CodeIgniter so they can be updated in a single place

I believe Smarty templates has functionality built in that allows you to manage your site URLs from a config file so if something gets moved, you only have to update the URL in one place. Does this sort of functionality exist in CodeIgniter? If not, any pointers or examples on how/where to add it?
For example:
Instead of hard-coding the link it would be: Settings
But where would you want to set $links so that it was available everywhere? Or is it really best to just hard code them?
Take a look at the config class. It allows you to make custom config files.
It's not entirely made for URL's but you sure can use them.
The base url should be basically right at the start of /app/config/config.php, where app is the name of your codeigniter application folder. You access it through calls to the base_url() function.
Yes, it's called Routes, configuration located at config/routes.php. Documentation
If you ask about the rendered html of the links, then your best bet would be using site_url() in conjunction with constants, for example site_url(URL_SETTINGS);, there is no built in functionality for that, but I can say I don't think that is necessary as it would be used too rarely, but it would influence performance every single load.

Resources