![]() ![]() This is done on line 42: $autoload = array('database','session') You can read more about it on the CI site, but one thing you'll likely want to do right away is enable your database and session libraries to load. The autoload.php file lets you name which files you want across the application. autoload.phpĬode Igniter gives you the ability to add only the libraries and functionality you need for your project. When you are ready to move the site, all you'll need to do is change your $active_group variable to 'production'. You can also create a second set of these variables called $db for example, with your live settings in it. MAMP automatically sets your username and password to root, and your MySQL port to 8889, so can copy and paste the above for working locally. It looks like this: $active_group = "default" ![]() This is the file where we'll set our database access - location, username, password, and database name. There are other settings in config.php you can modify to suit the framework to your needs, but those are the only ones I typically use. This is where you can setup your sessions to use the database, as outlined above. So in this case, I've changed it to: $config = " The next portion of code you might need to change is from lines 234-242, and it looks like this: $config = 'ci_session' but that's a more advanced procedure and not part of this tutorial. You can also edit your vhosts file to have it match your live url. You'll want to change it to your own install directory. On line 14, you'll see this: $config = "" In here are all the files that run the configuration settings. The first thing we'll do is open up the system->application->config folder. ) Step 5 Edit your Code Igniter Settingsįrom this point, you'll want to edit your CI settings to match your environment. Last_activity int(10) unsigned DEFAULT 0 NOT NULL, Ip_address varchar(16) DEFAULT '0' NOT NULL, Session_id varchar(40) DEFAULT '0' NOT NULL, Here it is: CREATE TABLE IF NOT EXISTS `ci_sessions` ( Code Igniter provides the SQL you'll need here, so you can click on the 'SQL' tab in phpMyAdmin and copy/paste the code in. In this case, I'm going to keep it the same. The default name of the sessions table is 'ci_sessions' - you can change this here and in the settings, but remember to do it in both places or this won't work. However, you'll first need to add the sessions table to the database. Enabling database sessions is fairly simple in CI, and we'll get to that further down. My personal preference is to use the database, because it provides greater functionality, and you don't have to worry about hitting your 4k cookie size limit. Otherwise, you can probably just copy and paste this: From there, create a new database (I've called mine 'ci').Ī note here: CI can handle sessions either with or without the database. From the links on top, you can select 'phpMyAdmin'. You can do this in MAMP by switching over to your running instance and clicking on 'Open start page'. Dynamic nearly always means database, so you'll have to create one. Odds are, you're following this tutorial so you can build a dynamic site in PHP. At that point, you should change the folder name from CodeIgniter_1.7.1 to whatever you want to use to describe your site. If you're using MAMP - the default is /Applications/MAMP/htdocs. Once you've downloaded and unzipped CI, you'll want to copy the folder over to your server root. You'll want to download it in order to continue to step 3. The involved community doesn't hurt either. What (I think) sets CI apart from other frameworks like Cake or Zend is its soft learning curve and strong documentation. ![]() Step 2 Download Code IgniterĬode Igniter is an MVC based PHP framework created by the makers of Expression Engine - a CMS/blogging platform. In any case, you'll want to download one of these two programs and follow the instructions for installation. If you're on a PC, you want to try out XAMPP instead (XAMPP also comes in an OSX flavor, but I haven't personally tried it). MAMP is the OSX version of the one-click Apache-MySQL-PHP install. While this tutorial is geared towards Mac users, most of the steps should be similar for Windows users. I recently downloaded the latest version of CI and began setting it up - when I realized the setup may be helpful to describe to newcomers to the PHP framework. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |