Asked  7 Months ago    Answers:  5   Viewed   37 times

when I had my site on development environment - it was url: testurl.com

Now on production server my codeigniter app's address has to be someurl.com/mysite/

I moved it there, and everytime I'm trying to run some function, example /home/test - it gets me into someurl.com/home/test - which is WRONG.

It has to be someurl.com/mysite/home/test - How to fix it? I did set

$config['base_url'] = someurl.com/mysite/

 Answers

33

Base URL should be absolute, including the protocol:

$config['base_url'] = "http://somesite.com/somedir/";

If using the URL helper, then base_url() will output the above string.

Passing arguments to base_url() or site_url() will result in the following (assuming $config['index_page'] = "index.php";:

echo base_url('assets/stylesheet.css'); // http://somesite.com/somedir/assets/stylesheet.css
echo site_url('mycontroller/mymethod'); // http://somesite.com/somedir/index.php/mycontroller/mymethod
Wednesday, March 31, 2021
 
PHLAK
answered 7 Months ago
44

I've used PHPExcel with CodeIgniter successfully before.

All I did was drop the phpexcel folder into application/third-party and created the following wrapper library:

<?php

class Excel {

    private $excel;

    public function __construct() {
        // initialise the reference to the codeigniter instance
        require_once APPPATH.'third_party/phpexcel/PHPExcel.php';
        $this->excel = new PHPExcel();    
    }

    public function load($path) {
        $objReader = PHPExcel_IOFactory::createReader('Excel5');
        $this->excel = $objReader->load($path);
    }

    public function save($path) {
        // Write out as the new file
        $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
        $objWriter->save($path);
    }

    public function stream($filename) {       
        header('Content-type: application/ms-excel');
        header("Content-Disposition: attachment; filename="".$filename."""); 
        header("Cache-control: private");        
        $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
        $objWriter->save('php://output');    
    }

    public function  __call($name, $arguments) {  
        // make sure our child object has this method  
        if(method_exists($this->excel, $name)) {  
            // forward the call to our child object  
            return call_user_func_array(array($this->excel, $name), $arguments);  
        }  
        return null;  
    }  
}

?>

I could then do the following in my controllers:

$this->load->library("excel");
$this->excel->load("/path/to/input.xls");
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->SetCellValue('B2', "whatever");
$this->excel->save("/path/to/output.xls");

Hope this helps you out?

Wednesday, March 31, 2021
 
CBroe
answered 7 Months ago
75

the problem is that the excel file is saved version 5, then I should Register with the 2007 version (. xlsx) and the Arabic values ??appear correctly in file properities:

$obj_writer = PHPExcel_IOFactory::createWriter($this->excel, 'Excel2007');
$obj_writer->save('php://output');
Saturday, May 29, 2021
 
BlueNile
answered 5 Months ago
61

Your RewriteCond is a bit wonky. I'm surprised it does anything at all, since it would seem to be trying to match the host www.domain1.com against the pattern www.www.domain1.com. These directives worked for me:

# Redirect www to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1$1 [L,R=301]
Thursday, September 16, 2021
 
The Coding Wombat
answered 1 Month ago
58

I think what I'm looking for is to add the following to the build.properties file:

project.root = ${basedir}

alternatively, I can just use the basedir property whenever project.root is needed.

I happened to be looking at the source code for ivy.properties and I saw the basedir property being used. I just tested and verified that this property works on different machines both from inside eclipse and from the command line as well as when making a call to ant from a different directory such as:

ant -f /path/to/eclipse/workspace/projectName/build.xml

When I get a minute, I will verify that this also works when importing the property file in different locations (such as inside src/main/resources/config/ivy/ivysettings.xml).

Monday, September 27, 2021
 
ajreal
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :