code igniter's localhost mamp model works but view does not - codeigniter

I have a strange problem:
I am using MAMP and Codeigniter and I see that view is not showing anything on the browser. Model works and the DB is wired up.
Here is the code that does not work on the local host:
$this->load->view('test/db_tester_view',$data);
Sadly there is no error messages!!? but here is the config:
$config['base_url'] = 'http://localhost:8888';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I spend 20 hours on this so your help is appreciated

Some tips:
Make sure error reporting is on, as usual (this should be in your bootstrap file, index.php):
error_reporting(E_ALL);
ini_set('display_errors', 1);
Make sure you did not disable these directives somewhere else in your script.
Windows and *NIX deal with uppercase/lowercase file names differently. Make sure your files are all normalized to lowercase to avoid problems with different operating systems.
The base url needs a trailing slash:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'http://localhost:8888/';
// OR...
$config['base_url'] = ''; // automagic
If you don't require the port to be set explicitly, you can remove it.

Related

How to upload Laravel 5 project to live web server

I believe it is much the same as a Laravel 4 upload.
I have my setup as follows, is this correct?
Is the only file I need to amend the index.php file which in my case is in the techjobs folder? I have amended this file to suit the directory structure. Are there any other files that need to change?
index.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylorotwell#gmail.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
require __DIR__.'/../../techjobs-laravel-base/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../../techjobs-laravel-base/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can simply call the run method,
| which will execute the request and send the response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
Right now you have too many steps back in your folders with ../ . Please try using below instead
require __DIR__.'/../techjobs-laravel-base/bootstrap/autoload.php';
and
$app = require_once __DIR__.'/../techjobs-laravel-base/bootstrap/app.php';

laravel 4 on shared hosting: PAGE NOT FOUND

Due to a client issue i have to put a laravel 4 application on shared hosting service.But i followed this process at [laravelio]which includes.
Place the files of the laravel public folder i.e. css, img, js etc; into public_html folder (don't dump public folder instead dump the files and folders in it).
Put all the remaining folders & files into another folder, say 'laravelcore' and place the laravelcore folder in the root (/home5/username/)
Open index.php in the public_html folder and replace the following lines as mentioned
require DIR.'/../bootstrap/autoload.php';
require __DIR__.'/../laravelcore/bootstrap/autoload.php';
$app = require_once DIR.'/../bootstrap/start.php';
$app = require_once __DIR__.'/../laravelcore/bootstrap/start.php';
Open paths.php file in laravelcore/bootstrap and replace the following line
'public' => DIR.'/../public',
'public' => __DIR__.'/../../public_html',
which is suppose to work but when i visit the url i get this : The requested URL /login was not found on this server.please what may be the problem as i dont get it.may be its about configuring the .htacces file.
Any help would be appriciated.Thanks
website is at :benin1897.com
i just discovered that there is no .htaccess file in th public_html folder.could that be the problem...
here is my file tree
(/home/benincom)
etc
logs
mail
oysg
app
bootstrap
vendor
publicftp
public_html
css
js
error_log
readme
pakage.json
robots.txt
tmp
NOW AM LOGGED ON BUT LARAVEL THROWS ME ERROR
/ / |-------------------------------------------------------------------------- | Register The Auto Loader |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader | for our application. We just need to utilize it! We'll require it | into the script here so that we do not have to worry about the | loading of any our classes "manually". Feels great to relax. | / require DIR.'/../oysg/bootstrap/autoload.php'; / |-------------------------------------------------------------------------- | Turn On The Lights |-------------------------------------------------------------------------- | | We need to illuminate PHP development, so let's turn on the lights. | This bootstraps the framework and gets it ready for use, then it | will load up this application so that we can run it and send | the responses back to the browser and delight these users. | / $app = require_once DIR.'/../oysg/bootstrap/start.php'; / |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can simply call the run method, | which will execute the request and send the response back to | the client's browser allowing them to enjoy the creative | and wonderful application we have whipped up for them. | */ $app->run();
Do you've got the route for login handeld in your /app/routes.php like this?
Route::get('/login', 'LoginController#login');
Or if you don't use Controllers ( Which isn't an good idea, but for quick / dirty testing... )
Route::get('/login', function(){
echo "Now we're going to login on this awesome website!!!";
});
More about the Laravel Routes
Edit 1
The Controller file ( /app/controllers/LoginController.php ):
<?php
class LoginController extends BaseController {
public function login() {
echo "Now we are going to login in this awesome website!!!";
// return View::make('pages/overig/login');
}
}
You stated that there isn't an .htaccess file in you public folder. There should be one.
Create the file and insert this content and try it again:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
It sounds like the .htaccess file is not configured properly so you are not getting the 'pretty URLs'. Try copying the example file from here to your .htaccess http://laravel.com/docs/4.2/installation#pretty-urls.
In the meantime you should be able to access your application by prepending index.php. For instance /login wasn't working for you, but if you try /index.php/login it will work

How to configure Laravel paths?

I'm a trying to install Laravel
My problem is:
/localhost/laravel displays its content like the folders under it.
but I am expecting something like the logo of laravel and the text "You have arrived."
I believe that the error is something in my paths.php:
return array(
/*
|--------------------------------------------------------------------------
| Application Path
|--------------------------------------------------------------------------
|
| Here we just defined the path to the application directory. Most likely
| you will never need to change this value as the default setup should
| work perfectly fine for the vast majority of all our applications.
|
*/
'app' => __DIR__.'/../app',
/*
|--------------------------------------------------------------------------
| Public Path
|--------------------------------------------------------------------------
|
| The public path contains the assets for your web application, such as
| your JavaScript and CSS files, and also contains the primary entry
| point for web requests into these applications from the outside.
|
*/
'public' => __DIR__.'/../public',
/*
|--------------------------------------------------------------------------
| Base Path
|--------------------------------------------------------------------------
|
| The base path is the root of the Laravel installation. Most likely you
| will not need to change this value. But, if for some wild reason it
| is necessary you will do so here, just proceed with some caution.
|
*/
'base' => __DIR__.'/..',
/*
|--------------------------------------------------------------------------
| Storage Path
|--------------------------------------------------------------------------
|
| The storage path is used by Laravel to store cached Blade views, logs
| and other pieces of information. You may modify the path here when
| you want to change the location of this directory for your apps.
|
*/
'storage' => __DIR__.'/../app/storage',
);
and index.php
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';
$app->run();
It's not your path. You should create a virtual host and point the virtual host's root to laravel/public.

Setting up magento site in sub domain

i have a magento site main domain.
i did the following steps :
1.Downloaded the full magento site from main domain(mydomain.com)
2.Created a sub domain as new.mydomain.com(in plesk)
3.Uploaded the full magento site in to sub domain.
4.Created new database and imported the database.
5.Changed the secure url and unsecure url as 'http://www.new.mydomain.com/' in core_config_table.
6.Changed the local.xml file with new database details.
The above steps i did.
Then i take the sub domain as new.mydomain.com in browser, but it goes to main domain(mydomain.com).
What is the reason for that?
I contacted the client, the client give me the information that, there is no server problem. It is in your code.
So what is the problem here?
Is there is any redirection to main domain from sub domain?
Or is there is any file taken from main domain instead of sub domain?
How can i solve this?
Are there any additional steps here i need to do?
I already checked the index.php page:
Here, i give an echo statement before Mage::run($mageRunCode, $mageRunType);
that is :
echo "test";
die();
Mage::run($mageRunCode, $mageRunType
Then the test will be displayed.
So when running mage it redirects to main domain.
fwiw: magento stores the "domain" information in at least two records in the core_config_data table:
mysql> select * from core_config_data where value like '%mydomain.com/';
+-----------+---------+----------+-----------------------+----------------------+
| config_id | scope | scope_id | path | value |
+-----------+---------+----------+-----------------------+----------------------+
| 4 | default | 0 | web/unsecure/base_url | http://mydomain.com/ |
| 5 | default | 0 | web/secure/base_url | http://mydomain.com/ |
| 1488 | stores | 2 | web/unsecure/base_url | http://mydomain.com/ |
| 1489 | stores | 2 | web/secure/base_url | http://mydomain.com/ |
+-----------+---------+----------+-----------------------+----------------------+
Before making the backup of the database, or even after backing it up, but before attempting to make the new site live, run an update statement:
update core_config_data set value = 'http://mynewdomain.com' where value = 'http://mydomain.com'
And then the site should come up fine.
Another method is to change the secure and the unsecure urls in the System->Configuration->web section and then saving the database.
SS
Have you clean cache ? ( removing /var/cache dir ) ?
You can try by phpmyadmin searching for mydomain.com in all the database and change it.

How to set date.timezone for CodeIgniter to work with php 5.3

When date.timezone in php.ini is commented out, it gives me:
A PHP Error was encountered
Severity: Warning
Message: main(): It is not safe to
rely on the system's timezone
settings. You are required to use
the date.timezone setting or the
date_default_timezone_set() function.
In case you used any of those methods
and you are still getting this
warning, you most likely misspelled
the timezone identifier. We selected
'America/Los_Angeles' for '-8.0/no
DST' instead
Filename: controllers/helloworld.php
Line Number: 2
When I have
date.timezone = "America/Los_Angeles"
It gives me this:
Server error The website encountered
an error while retrieving
http://localhost/ci/index.php/helloworld.
It may be down for maintenance or
configured incorrectly. Here are some
suggestions: Reload this web page
later. HTTP Error 500 (Internal Server
Error): An unexpected condition was
encountered while the server was
attempting to fulfill the request.
I am using php 5.3, CodeIgniter 2.0.0, and Apache 2.2.
Update 1:
I tried loading a test.php without CodeIgniter, where the first 3 lines of test.php is
date_default_timezone_set('America/Los_Angeles');
echo date("l j \of F Y h:i:s A");
And it works fine, different timezones also works fine too.
So I suspect the problem is from CodeIgniter.
If you Googled "CodeIgniter PHP 5.3" you would have found this article pretty quickly :)
http://philsturgeon.co.uk/blog/2009/12/CodeIgniter-on-PHP-5.3
To fix this, you only need to edit the main index.php for your CodeIgniter application:
if( ! ini_get('date.timezone') )
{
date_default_timezone_set('GMT');
}
This modification is something you will probably need to make for any CodeIgniter application running on PHP 5.3 and can easily be modified to your local timezone. There is a full list of supported timezones in the PHP manual here.
Yes, if you cannot directly edit the php.ini file, placing...
ini_set('date.timezone', 'America/New_York');
...as the first line in CI's index.php works fine.
Reference: PHP's Available Timezones
write in your index.php codeigniter...
/*
|---------------------------------------------------------------
| TimeZone
|---------------------------------------------------------------
|
| default Time Zone
|
*/
if ( function_exists( 'date_default_timezone_set' ) )
date_default_timezone_set('Asia/Jakarta');
Running well in my codeigniter
this is the simple way to do it
$timezone = "Asia/Calcutta";
if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
//echo date('d-m-Y H:i:s');
$localtime=date('H:i:s');
$sql="INSERT INTO hits (ip,edate,curtime,page_name) VALUES ('$ip', CURDATE(),'$localtime','$filename') ";
date.timezone is intended to go in your php.ini or .htaccess file.
you could do an ini_set('date.timezone', 'America/Los_Angeles'); in the first line of your script and get the desired results.
edit your config.php file
from
$config['time_reference'] = 'local';
to
$config['time_reference'] = 'UTC';

Resources