ExtJS and autoloading URL - php

I am using a php framework which requires an index.php file to be used (can be removed with .htaccess, but I would prefer not to do so in my current situation). the problem is that in some cases ExtJS is autoloading classes at URL's like the following
mysite.com/index.php/path/to/file.js
Is there a way to set the URL in which the ExtJS classes will be loaded from?

If you are using app.js and loader then you need to set 2 things:
appFolder property on your Ext.application config
and the path config on the Loader for any other components outside your app structure.
Like this:
Ext.application({
name:'MyApp',
appFolder:'js/MyApp/app'
and
Ext.Loader.setConfig({
enabled:true,
paths: {
'Ext.ux': 'js/extjs/ux'
}

Related

bootstrap.php file in CodeIgniter PHP framework?

I am new in php. I am learning Code Igniter (a PHP framework). Can anybody let me know is there any bootstrap.php file in codeIgniter ? And if yes then what it does?
I googled but no luck for bootstrap.php file for CodeIgniter, however i got the bootstrap.php file for Zend and one other framework.
Many Thanks.
application/config
From the question, I'm assuming you would like to know where this file is to add something to it.
The bootstrap file in CakePHP is for additional application settings and setup logic - the equivalent file in Codigniter is probably the application/config/config.php file.
The bootstrap file in Zend contains a class used for initializing the whole application , which by default reads a config.ini file. Depending on specifically what it is you're looking for in "bootstrap.php file in CodeIgniter" - again, the application config files are the CI equivalent of this file's logic/purpose.
The CodeIgniter bootstrap file is the CodeIgniter.php located in system/core.

how to include file in zend framework controller?

hello I am newbie in zend framework ..
I want to know how to includes files in zend framework Controller
I am using action in zend framework controller like that
public function anyAction()
{
require("../mailchimp/anyfile.php");
}
what I can do to include this files, means where is the right place to kept all this files
This is what the library directory is typically used for. You can put your own functions in there as well as any 3rd party code. Some even put the ZF library in there, but I tend to keep ZF elsewhere on the server and add it to the include_path in php.ini.
With the mailchimp files in your library folder, you can include them like this:
require_once APPLICATION_PATH . '/../library/mailchimp/MCAPI.class.php';
If you add library to your path, then you could shorten it to just:
require_once 'mailchimp/MCAPI.class.php';
You can add library to your path by adding includePaths.library = APPLICATION_PATH "/../library" to your application.ini file. Just be aware of the possible performance penalty you may take by adding additional locations to your include_path.
EDIT:
To display an image that you have stored in public/images, you would use this call from your view/layout:
<img src="<?php echo $this->baseUrl('images/file.jpg') ?>" alt="file.jpg" />
This takes care of figuring out what your base URL is in the event that your Zend Application is not in the root directory of your domain. See the BaseUrl View Helper for more info.
In Zend-Framework you must follow MVC pattern to create any page. when you want to use/call this page you write url using module, controller and action like bellow:
require($this->url(array('module'=>'default','controller'=>'mailchimp','action'=>'mailchimp')));

CodeIgniter - extend native library in multiple-site setup

I want to use a central CI setup for multiple sites. The way I handle this is I created a package called MPACK and added it to autoload in the config file of each site.
Folder Structure:
/main
/system (CI 2 System folder)
/MPACK
/site1
/application
site2
/application
Inside this MPACK I have share libraries, models, helpers, etc.
However, I would like to have an extended MY_Form_Validation that would be common to ALL sites. Adding the class file to /MPACK/libraries fails. Adding it to /site1/application works fine, as expected.
Is there any way to do this extending inside MPACK?
Thank you for your time.
Please try this:
// Placed your MY_Form_validation.php under MPACK/libraries
$this->load->add_package_path('/path/to/MPACK');
$this->load->library('form_validation');
You can get more information from CodeIgniter User Guide - Loader Class. :)
You can also autoload your package in /application/config/autoload.php : $autoload['packages'] = array('/path/to/MPACK');
EDIT: turn out that the above solution doesn't work, because Loader always look for APPPATH & BASEPATH first, and I not sure modifying this core class won't break something. Here is another solution in theory:
You should have your MPACK form validation lib, and sites' form validation lib should be symlinks to the MPACK one:
/site1/application/MY_Form_validation.php -> /MPACK/libraries/MY_Form_validation.php
If you just use everything from MPACK, nothing specifically for /site1 or /site2, just make a folder link:
/site1/application/libraries/ -> /MPACK/application/libraries/
Hope this help =)
You can read more here: http://codeigniter.com/wiki/Multiple_Applications_via_Symlinks/

In which folder to place the classes that I extend in the Kohana 3.1 framework?

I am new to the kohana php framework. In the modules folder in kohana 3.1, there are many empty files extending the existing classes. Should I write my code in those empty files?
If yes, do I have to make any changes in bootstrap?
If not, where should I place these files? Should they be in a subfolder inside the Application directory or inside the modules directory?
Which all files will I have to copy from the modules to application?
Those empty files you see are aliases created for the class. An example would be the Cookie class, declared as so:
class Cookie extends Kohana_Cookie {}
It's just another way for you to refer to the real class, in this case Kohana_Cookie, without having to type all that out.
So when you use something like Cookie::salt($name, $value) you're really just using Kohana_Cookie::salt($name, $value).
If you want to extend a class, you can drop the files into your application/classes folder and go from there.
check out the docs at http://kohanaframework.org/3.1/guide
especially: http://kohanaframework.org/3.1/guide/kohana/files
you can extend classes in the folder: application/classes/.. or modules//classes/..

Trouble setting up php Zend include path

I am trying to set up a PHP path to my Zend Framework. I am very confused on how to do this. My Zend Framework is located at the following location on my server:
amazon/ZendFramework-1.10.3-minimal
I am going to be creating a couple of php files in the amazon/ directory that will require the Zend Framework. My include path is:
include("ZendFramework-1.10.3-minimal/library/Zend/Service/Amazon.php");
However inside of Amazon.php is the line
require_once 'Zend/Rest/Client.php';
...and then Client.php has more dependencies set up like that, and so on.
How can I set up my include path so that Amazon.php and Client.php (and so on) can correctly reference the location of the Zend Framework?
Thanks
You will have to set your include path using set_include_path() in your Bootstrap file if you are using any. (need to check the ZF layout for details if you are using the ZF).
The Loading of the classes will be handled by the Zend Loader when you include the library/Zend/Loader.php file and calling the function that will enable the automatic loading of classes that reside in your library/Zend folder.
When you set the include path to your library, include the library/Zend/Loader.php and call Zend_Loader::registerAutoLoad() I believe will be able to work without problems.
Short example in a file called bootstrap.php
set_include_path('ZendFramework-1.10.3-minimal/library/'.get_include_path());
require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();

Categories