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';
Related
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.
I'm thinking of using the Recess Framework which I downloaded as-is and followed the instructions studiously.
I'm using it with PHP (which is not the issue) and I seem to have it up and running... however I suspected something was slightly wrong with the pages being served (they did not contain the expected logos) so I inspected the code only to find out that the frameworks javascript and CSS files were "resource not found".
Incidentally the files exist at the path specified, and it's not a question that permissions are not set correctly - I checked that too.
But... I'm new to using "routing" through URLs as part of a MVC style and wondered if basically it has something to do with that.
If you download the framework, you'll find that the css and javascript files that make things look pretty, and activate certain parts of the framework toolset exists at the path:
http://localhost/yourRecessFolderName/index.php/recess/recess/apps/tools/public/js/shCore.js
but I get the dreaded 404 resource not found and this is preventing recess tools from working properly.
1) Has any body else had this or a similar problem?
2) What are the likely causes - help by pointing me in the right direction, unless you know the answer of course
On Recess v0.2, there is an .htaccess file in /apps that prevents direct access to children. You'd need to modify the .htaccess or configure something custom in mod_rewrite to allow the public folders under apps to be seen.
Well, seemed to fix it by downloading the most recent ("latest edge") version of the Recess framework from https://github.com/recess/recess
Everything seems to work fine now... hmm 0.o
When pass from Development to Production, the Recess Framework use a Cache for accelerate access to site. Is possible, in your case, that the cache content is wrong.
I suggest you access path /your/recess/path/data/temp and remove the files recess.php and sqlite-cache.db and try again.
I hope this help you.
I have just installed CakePHP 2.1. And just see that the naming convention of its is just change lot from the older version which making me crazy.
Like it was app/controllers while now it is app/Controller same way
app/models - app/Model
app/views - app/View
I know there must be some advantage on doing this. But my problem is when I use the cake bake it is creating directory in the same old fashion i.e. controllers/models/views. Which is no more accessible from the URL & obviously will throw an error.
Is anyone there who has face the same issue ? Is there any solution that cake bake also use the same conventions ?
Any help will be appreciate. Thanks.
you can always use explicit paths:
/path/to/app_dir>..\lib\Cake\Console\cake bake
from your APP dir of the current cake project.
this is foolprove and always works with the right cake version.
I do it this way and use a shortcut on my keyboard to print this (up to "cake") on a single key stroke.
The reason for the change is to be able to better autoload files based on their kind (using App::uses('User', 'Model'); and later , when namespaces are introduced (3.0?) they can be loaded a lot more easy because you will call a class then like for example: "new \Cake\Model\User();"
About your bake problem: Make sure your environment is pointing to the correct "cake" shell file. I'm pretty sure yours is still pointing to the old 1.3 "cake" shell.
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.
What is the best way to integrate an external script into the Zend Framework? Let me explain because I may be asking this the wrong way. I have a script that downloads and parses an XML file. This script, which runs as a daily cron job, needs to dump its data into the database.
I am using Zend Framework for the site which uses this script and it seems to me that it would be best to use my subclassed model of Zend_Db_Abstract to do the adding and updating of the database. How does one go about doing this? Does my script go in the library next to the Zend Components (i.e. library/Mine/Xmlparse.php) and thus have access to the various ZF components? Do I simply need to include the correct model files and the Zend DB component in the file itself? What is the best way to handle this sort of integration?
Yes, you should put your own classes that maybe inherit Zend Framework classes or add further classes into your own folder next to the Zend Framework folder in library.
When you have Zend_Loader s auto-loading enabled, the class names will automatically map to the class you created, e.g.:
My_Db_Abstract will map to My/Db/Abstract.php .
In your library directory you should have your own library next to the Zend library folder. Whatever you call it (Mylib, Project, ...) you should include it into the Zend Autoloader and that's done as follows:
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Project_');
$loader->setFallbackAutoloader(true);
if ($configSection == 'development')
{
$loader->suppressNotFoundWarnings(false);
}
In order for you library to integrate nicely with ZF and the Autoloader you should stick to the ZF naming conventions. This means two things:
if you extend an existing ZF class, replicate the ZF folder structure so that your file has the same path and name except for the library name. E.g. /library/Zend/Db/Abstract.php => /library/Project/Db/Abstract.php.
if you write your own classes, still stick to the ZF naming conventions for the autoloader to find them.
I just came across something that may be germane to this question. This IBM developerWorks article.
The author recommends simply creating a scripts folder in the ZF hierarchy and the using it as one normally would within ZF (though he does set the ini path and call autoload). Is it that simple? Does simply being in the hierarchy of the framework and including the path and autoloader grant your script access to all of the goodies?
I'm not 100% sure what you're trying to ask but I will try to help. If at any point you add a reference to "/path/to/zend/framework" into your php include path then you have in essence enabled the Zend Framework. From there if you do:
require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();
Then at any point in your script you can pretty much just create new Zend Framework objects and Zend_Loader will handle the rest.
One of the big things about the Zend Framework though is not forcing you to do things a certain way. That's why sometimes there are several ways to accomplish the same thing. So, if you feel you need to make your script use the Zend Framework just for the sake of doing so this is not really necessary. But if you think it may improve your script in some way then go for it.
I usually put custom stuff that I think could be used across projects in a custom folder in the library. So I have a library/Ak33m folder that has scripts that may be outside of the framework.
As a ZF noob myself, I think I understand some of what the OP is trying to figure out. So, I'll just explain a bit of what I understand in the hope that it is helpful either to the OP (or more likely, to a future reader, since the original question is so old and I imagine that OP is now a ZF guru).
I understand that ZF claims to be largely "use at will", so that you need no buy into an entire structure, like the Zend_Application, the Zend_Bootstrap class, the entire MVC approach, etc.
Further, I understand conventions for class naming and file locations that enable easy autoloading. Ex: class App_Model_User resides in a folder App/Model/User.php
I think what can be potentially confusing is that in the script context, where you have not yet
done the .htaccess magic that pushes all request to public/index.php
set your APPLICATION_PATH and include paths in public/index.php
created your Application or Bootstrap object tied to a config file
it can be a little bit unclear how best to avail yourself of most of the ZF goodness we get in that context and want in another context.
I guess my answer to the original question would be that the usual entry point sequence of
http request -> .htaccess -> index.php -> config
sets up much of our environment for us, we would need to duplicate some of that for different entry path.
So, for your script, my first instinct would be to create a common include file that mirrors much of what happens in index.php - set the include paths, the APPLICATION_PATH, instantiates and calls a bootstrap, and then does your script-specific processing.
Even better, it might be desirable to create a single entry point for all your scripts, like we do in the http/web context. Extend Zend_Application for your own script purposes so that $application->run(); no longer starts up the MVC router-controller-dispatch processing, but rather does your own stuff. In that way, this single script entry point would look almost identical to the web entry point, the only difference being which application object gets instantiated. Then pass the name of your desired Application class as a command line parameter to the script.
But here I confess to being less confident and just throwing out ideas.
Hope all this helps someone. It actually helped me to write it all down. Thanks and cheers!
Update 2009-09-29: Just ran across this article: Using Zend Framework from the Command Line
Update 2009-11-20: And another article: Cron jobs in Zend Framework | GS Design
Update 2010-02-25: Easy command line scripts with Zend Application - David Caunt