Codeigniter use Codeigniter models from outside script - php

There was a great post that applied to CI 1.7.2 about using CI models outside CI. It worked like a charm.
http://codeigniter.com/wiki/Calling_CI_models_from_outside_script/
Then I upgraded to 2.0 and the code written in the above post was no longer applicable. I am having a hard time trying to get this to work in 2.0. The Config.php file is no longer in the libraries folder in addition to the Language.php and Model.php files.
Does anyone have an idea of how to port this to 2.0 ?
I only need the models. I was using them in an incoming email extension to our application and using the CI models that we had written saved a lot of time. Any help would be greatly appreciated. . .

I have no idea what this package does, or what issues you're having (forgot to say?), but in 2.0 you need to be looking in the "core" directory rather than the "codeigniter" directory.

Related

How we setup cakephp 3.x without database?

In our project we don't need a database, so how do we setup cakephp 3.x on a local machine without modifying the database config? I have this issue when I'm running my site.
Error: Class 'PDO' not found
File /usr/share/nginx/dchannel/vendor/cakephp/cakephp/src/Database/Type.php
Line: 100
So please suggest a better way to do disable the database on cakephp 3.x
Thank you in advance.
Theoretically that should be possible if you just avoid to touch anything that interacts with the datbase, or uses PDO related constants and stuff, like the Type classes that are by default involved in the applications bootstrap:
https://github.com/cakephp/app/blob/3.5.0/config/bootstrap.php#L174-L189
Also you cannot use Migrations or DebugKit, as both require PDO:
https://github.com/cakephp/app/blob/3.5.0/config/bootstrap.php#L206-L207
https://github.com/cakephp/app/blob/3.5.0/config/bootstrap.php#L211-L217
If you comment these snippets, and do not touch the model layer anywhere, then it should work. However I don't think that there is a guarantee that this will continue to work. If you want to make sure you can ask the core devs over at Slack or IRC, or maybe even open a ticket on GitHub.
I think it is possible because cakephp use its own design template. so just replace the template with your one .
php default template \src\Template\Pages\home.ctp
I don't think it's possible to set up CakePHP without a database; it is basically a frontend to a database so the tool doesn't work without one, and I think it also uses it to store some of its configuration. If you don't need a database, then I advise you choose a different framework.

CodeIgniter 3.1.4 - Implementing evert's Sitemap PHP Library

I'm trying to get evert's sitemap-php library working in CodeIgniter using the vague instructions that I found in another StackOverflow post, but I'm not having any success. I've got a few questions that should be enough to point me in the right direction when answered:
Should the makeSitemap() function be added to the default controller?
If evert's Sitemap.php file is placed in the libraries folder (instead of nested in the SitemapPHP folder like the example), can it be loaded properly using the standard CI syntax?
$this->load->library('sitemap');
Where does the sitemap folder belong?
I'd greatly appreciate any insight on these questions. Unless someone beats me to it, I'll be sure to post a code-based solution once I get this working.
You can do it on two ways. First would be modifying Sitemap.php code including property (i.e. $CI) and getting codeigniter's object by reference in constructor as described in documentation. However second way would be using composer autoloader and IMHO that should be your prefered way. In this answer I described how to use github repository in CI application but there is more answers and articles that can point you in right direction how to use composer in CI.
If you go with first way, you would call $this->sitemap->method() and if you would go with second method, you would use library as described on github's readme section.

How i can extend the Codeigniter library in Pyrocms

I want to add some more library and helpers file into Pyrocms which is based on codeigniter.Actually i have to add facebook connect and found some good working examples of facebook connect so now i want to implement these codeingiter libraries and other files in Pyrocms.Let let me know where to put these libraries. Your help will be appreciable.
since version 1.3.0 addons/default/libraries
or addons/shared_addons/libraries for the pro version. (This bit will help on the where to put stuff topic...
http://www.pyrocms.com/docs/1.3/manuals/developers/understanding-the-addons-directory )
Then load the lib in your controller, etc as such $this->load->library('cool_facebook_connect_lib');
And, depending on your version you may have to change around a couple lines in MY_loader for it to work, http://www.pyrocms.com/forums/topics/view/18087

Strange (for me) behavior of YII framework

I use YII framework and I needed to echo out query that is generated with the method insert($attributes=null) in CActiveModel class which, as it's told in documentation, is in framework/db/ar/CActiveRecord.php.
Well, my task was not hard, so I opened this file and edited this method, but nothing happened. After a little head-ache I've found out that my application was importing this class from the folder where I downloaded YII first.
What could be the reason of this behavior? I've solved my problem by changing path but I wonder, is it good solution?
Thank you in advance.
It's on index.php where you tell your application where to find the classes of the framework, so that's the line you should edit.
// change the following paths if necessary
$yii=dirname(__FILE__).'/../yii/framework/yii.php';

Luracast Restler in CodeIgniter

I am trying to put in Restler as part of my CI Library. I wonder if this is possible with Restler because I'm getting Server Error. Should I just separate Restler folder to my CI folder (which works right now)?
I want to integrate it to my CI so I can access the models e.g for authentication, getting user data...etc. instead of creating another config file and model classes.
I have invested a lot of time trying to find some workaround to make Restler work with CI but no luck.
Thanks!
I don't think there's an easy way to integrate Restler into CI, you would have to totally rework the CI routing class.
I would recommend that you instead go with Phil Sturgeon's excellent REST server for CI, which is a pretty simple to put into your existing CI application.

Categories