CodeIgniter in hostgator doesn't work - deployment

I trying to deploy a CodeIgniter2 project in HostGator. It should be easy right?? I'm changing this in config/config.php
$config['base_url'] = 'http://example.com';
in config/database.php I change this
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'the username';
$db['default']['password'] = 'the password';
$db['default']['database'] = 'database name';
in index.php
define('ENVIRONMENT', 'production');
when I type http://www.caribeanrenta.com in my browser, I get Error 404 not found form codeigniter.
What's wrong, am I missing something??

Finally!!!, it was all about case sensitive, I work in window and the names of all controller and model clases are capitalized, but in linux, which is the server that I'm deploying, doesn't reconized lower case controllers and models, so change everything to lower and everything works now.

I had the same problem, resolved it by setting the first letter of controller files uppercase. Example: I had controller user.php and renamed it to User.php and it worked.

Related

SilverStripe 3.1 - Wrong $BaseDir after porting to XAMPP

after porting my fully working SS3.1 Page from my Webserver http://mydomain.de to my locally installed XAMPP http://intranet/silverstripe I've got the problem that the Base Directory is now wrong in SS. It's the old one from the webserver / but it need to be /silverstripe
I already changed it in the .htaccess so that mod_rewrite works but $BaseDir returns / and if I try to use the SS Sitesearch than I get redirected to home/SearchForm?Search= instead of silverstripe/home/SearchForm?Search= after submitting the form.
Can someone please help me to fix this problem.
Thank you in advance
EDIT:
I just call $SiteSearch in my Template.
But the function is modified in my Page.php to search also through a dataobject.
public function results($data, $form){
$results = $form->getResults();
$query = htmlspecialchars($data['Search'], ENT_QUOTES,'UTF-8');
$objects = ListingObject::get()->where("MATCH (Title, Link, Company, Category) AGAINST ('$query' IN BOOLEAN MODE)");
$results->merge($objects);
$data['Results'] = $results;
$data['Title'] = _t('SearchForm.SearchResults', 'Search Results');
$data['Query'] = $query;
return $this->customise($data)->renderWith(array('Page_results','Page'));
}
without this code it also doesn't work
SOLUTION:
I'm sry. I found the Problem. I didn't call $SiteSearch, because when I created the Page, I had to edit the form, so I hardcoded it... because of that, the submitted url is wrong now. I'm so sorry!
$BaseDir should be $BaseHref in your template.
You might have to set an alternate base url in the SS config. Add this to your config.yml:
Director:
alternate_base_url: '/silverstripe'

How to handle Zend Framework End User INI/Config settings

I have searched and searched for this but I think my terminology isn't correct as it keeps giving me the application settings for the zend site rather than an application settings for the End User.
I'd like to have a config.ini type file that the end user can edit values in. I'd like it to be ONLY the settings I wish them to see and to be able to create the value names as I think would make sense to them. So it would be something like
[General]
SiteName=MySite
ShowResources=TRUE
[Database]
Server=myServer
databasepath=mydbpath
...
So my two questions.
1. What is this type of file called because when I search application settinsg, I get the ZF application settings not one for an end user (presumably)
What is the best way to handle this type of file?
Thanks
In your bootstrap add:
protected function _initConfig()
{
$config = new Zend_Config_Ini(APPLICATION_PATH.'/configs/config.ini');
Zend_Registry::set('config', $config);
return $config;
}
replace config.ini with whatever you want the filename to be.
You can then access this config object anywhere in your application either as an application resource or through the registry (Zend_Registry::get('config')). So to get the SiteName from your example:
$config = Zend_Registry::get('config');
echo $config->General->SiteName;
For things like database settings, you'll want to access these in the bootstrap so you can use them to setup other resources. I would recommend you don't try and include database settings in your application.ini as well, instead manually setup the DB resource by adding another bootstrap method:
protected function _initDb()
{
$this->bootstrap('config');
$config = $this->getResource('config');
$db = Zend_Db::factory('Pdo_Mysql', array(
'host' => $config->Database->Server,
'username' => $config->Database->Username,
'password' => $config->Database->Password,
'dbname' => $config->Database->Dbname
));
return $db;
}
To explain this some more, $this->bootstrap('config'); ensures the config resource is loaded first. $this->getResource('config'); returns the config resource (the one created by the _initConfig() method). It then uses the data from this object to create the DB connection.
It's an INI file, which you can read and write via Zend_Config.
ZF has no concept of "user settings" -- users are defined by you, not by the framework.
Apps usually store user configs in a database, but that's totally up to you. You could store a directory of INI files instead. Either way, you have to do the implementation yourself.
Edit: Given that you have a ZF app that you're distributing to the customer, and they're only ever going to connect to one database with it, that changes things significantly. (I thought you originally meant that you'd have one instance of the app simultaneously connecting to multiple databases.)
In your case, I would use the standard ZF application/configs/application.ini file for your application's "internal" settings. Then, I'd have a separate local.ini (or whatever) in that same application/configs directory, which contains only those settings that you want the customer editing. Distribute a skeleton local.ini file with the app, that has instructions right in it, something like this:
; Remove the comment from this line.
;configured = 1
; You need to put your database credentials in here.
db_host = "PUT YOUR DATABASE SERVER NAME HERE"
db_user = "PUT YOUR DATABASE USERNAME HERE"
db_pass = "PUT YOUR DATABASE PASSWORD HERE"
Then just load the local.ini file via Zend_Config. I'd also add a check to your index controller's init method that checks to see if you're properly configured:
$localConfig = Zend_Registry::get('local_config'); // or wherever you put it
if (!$localConfig->configured) {
$this->_helper->redirector('config', 'error');
}
And then make a error/config view that says:
You didn't read the instructions. Go do that now.
Note there's nothing stopping the customer from editing anything they want, but this makes a logical separation and makes it harder to accidentally screw something up.

view helper in zend framework 2

the thing is these this lines:
$loginUrl = $this->view->url(array('controller'=>'auth', 'action'=>'index'));
$registerUrl = $this->view->url(array('controller'=>'register', 'action'=>'index'));
based on rob allens' Zend_Auth login/logout tutorial (win7/apache),
are placed in a view helper, and this one:
echo $this->url(array('controller'=>'index','action'=>'add'));
is placed in the index view script.
The generated links Do work fine in LOCAL, but in REMOTE only the 3rd line works.
ANY IDEAS? Where should i look for this? wich way to follow?
I was tempt to think in the remote server conf but the 3rd line works fine, so..
thanks!
Try this helper instead of view Zend_Controller_Action_Helper_Url:
//simple($action, $controller = null, $module = null, array $params = null)
//so your lines will look like:
$loginUrl = $this->_helper->url->simple('index','auth');
$registerUrl = $this->_helper->url->simple('index','register');
P.S. your lines work properly on Win7 and Ubuntu servers check registry of the lines
I found out that was the server. (.htacces and mod_rewrite) was not included in the package.
I think the third line was working because it was in the index controller, but when calling the others, then happened the object not found.
To work out this, i found an example using zend debug (was in german) so i inferred it (and then wrote to the hosting service), but still not quite sure how to check (phpinfo?) if a host have this features available or not in your package.

Zend Framework unknown module is interpreted as default module

i wanted to support multilingual structure for my work i used the following lines
$controller=Zend_Controller_Front::getInstance();
$router=$controller->getRouter();
$languageRouter=new Zend_Controller_Router_Route(":lang/:module/:controller/:action", array("lang"=>"en","module"=>"default","controller"=>"index","action"=>"index"),
array("lang"=>"[a-zA-Z]{2}"));
$router->addRoute("default",$languageRouter);
it works fine http://localhost/zend/public/en set the lang param to en and call default module
but the problem is that when i use url like this http://localhost/zend/public/en/anything
where anything isn't module it still show the default module how to prevent that???
after the answer of takeshin i added this function to the bootstarp file and now it works as i want it
protected function _initRoutes()
{
$routeLang=new Zend_Controller_Router_Route(':lang',array('lang'=>'en'),array('lang'=>'[a-z]{2}'));
$front = Zend_Controller_Front::getInstance() /*$this->getResource('frontcontroller')*/;
$router = $front->getRouter();
$routeDefault=new Zend_Controller_Router_Route_Module(array(),$front->getDispatcher(),$front->getRequest());
$routeLangDefault=$routeLang->chain($routeDefault);
$router->addRoute('default',$routeLangDefault);
$router->addRoute('lang',$routeLang);
}
It looks like you have overwritten default module defined in Zend Application by your custom one.
You should chain the routes instead.
The settings you are using means module will 'default' to default , if you didn't it would throw a route not found error - which should throw to appropriate error controller
I'm not sure if I unterstood this correctly, but it looks like it works fine, as it should. If you try to call non existing module, Zend Framework automatically "redirects" to the default module.

Zend framework: how to migrate a site

I'm trying to copy a site built on ZF from production to a localhost environment. All files and db contents were copied but I just get a blank screen. No errors, nothing
Changes made in config.ini I added an entry for development:production
general.host = "localhost:8888"
db.adapter = PDO_MYSQL
db.params.host = localhost:8888
db.params.username = bla
db.params.password = bla
db.params.dbname = db_name
bootstrap.php
$frontController->registerPlugin(new Initializer('development'));
.htaccess contains a few basic directives but if I put some random stuff at the top I don't get Internal server errors so I don't think it even reaches the .htaccess stage.
Did I miss some kind of configuration somewhere?
EDIT:
I have code below in my bootstrap but still get a blank page. Very quickly, it barely loads at all
$frontController->registerPlugin(new Initializer('development'));
$frontController->throwExceptions(true);
// Dispatch the request using the front controller.
try {
$frontController->dispatch();
}
catch (Exception $exception)
{
exit($exception->getMessage());
}
Try adding this line before running dispatch() on front controller object.
$frontController->throwExceptions(true);
On production systems throwing exceptions is almost always disabled, enabling it on dev could tell you more about the nature of the problem.
Yes, you probably missed some configuration.
Try setting display_errors=On in php.ini. You should be able to see what is going on.
Also, like suggested - try putting $frontController->throwExceptions(true) before calling dispatch().
Regarding the .htaccess file - you need to put the AllowOverride All (or anything valid, other than None) in your apache.conf/vhosts config.