Welcome Guest, Not a member yet? Register   Sign In
A couple of teething questions on the mechanics of embedding CI into one's website
#1

[eluser]buffalobill[/eluser]
Part One

I have a couple of specific beginner questions on the mechanics of how to embed the relevant parts (of the CI program into one's website, so that one can begin to follow the tutorials in a DIY manner (with the aim, of course, of learning to do more substantial stuff). First of all, I presume that there is no way that one can call up a CI PHP file on one's PC, rather than on one's website? (I note that the URI (actually URL, I reckon) listed in the text-only tutorial (TT), reflects a webaddress). I have tried to access, on my mirror-image "website" on my PC, the files I created while following the TT, but it just didn't work. Trying to mimic the webaddress URL, I wrote the following URI in MS Word (it became a link), then clicked on the link to see if it would take me to the target file (blog.php in this case) in the mirror-image folder of my website located on my PC (no luck, by the way):

file:///C:/mydomain/index.php/blog/ (if this were my website, the URI would read: http://www.mydomain/index.php/blog/).

I can easily access any HTML file on my old, non-PHP mirror-image "website" on my PC. In fact, I usually run through a new posting on my mirror site before uploading it, just to make sure that I didn't make any glaring mistakes, like incorrect linkages to image files.

Second problem: I reckon that the relevant part of the CI program to place on my website is the "system" folder, renaming "system" to reflect the name of my main (but not root) website folder, as suggested (I believe this to be the case, but I will return to this in a jiffy) in the index.php file of the "system"\application folder (when accessed with a text editor)? I have no doubt that it is not necessary for me to copy the "user-guide" folder to my website in order to follow the TT as long as I can post the relevant target files to my website where they can (presumably!) be accessed (more on this in a jiffy too), i.e., I can just run the tutorial from the mirror-image "website" on my PC, then check the newly-created, new-y-posted PHP file via my www website.

For what it's worth, my old website (cheapest hosting plan, no CGI-, no PHP support) had an unnamed root folder in which my main folder, i.e., the folder name I gave it, say, mainstreet, was located, and in which all of my files were located. There were no loose files at all in the unnamed root folder, only the subfolder (my main folder), mainstreet. The setup was like so: unnamed_root_folder\mainstreet (and with Stats and Images subfolders to mainstreet).

My new website (with a more advanced hosting plan), which does indeed support both CGI and PHP, is structured slightly differently. I still have a setup similar to the above, say, unnamed_root_folder\highstreet, but the main, or "index.html" file must be located, says the host, in the unnamed_root_folder. All I had to do to link to all the other files in the highstreet folder, of course, was to add "hightsteet" to the path of the next file in the sequence which the index.html file points to. Assume that the index.html file is a simple welcome page and when one clicks on the relevant field on the welcome page, one is redirected to the mainpage.html file. If this were my old site, I could just assign the href in the index.html file to "mainpage.html". With the new site, this must read: "highstreet/mainpage.html".

Part Two to be continued (I'll be back!)
#2

[eluser]buffalobill[/eluser]
Part Two

None of this of course affects my CI folders, I reckon, because the PHP stuff will only be called up from inside my main, or "system", folder (highstreet). That is, since the key index.php file is located in the application subfolder (on the highstreet\application path), there is nothing to worry about w.r.t. the CI-designated path as long as I do not make any changes to the "system" (highstreet) folder setup, other than to rename it, as I have done, to reflect the name of my main folder, in accordance with the documentation provided in this key index.php file. In fact, according to that documentation, there are only two parameters which users can alter in the index.php file, namely, the name of the "system" folder and something else, which I had intended to bullet below, but which I might as well just jump into right here, called "error reporting". The documentation in question says: "By default CI runs with error reporting set to ALL. For security reasons you are encouraged to change this when your site goes live." And here is the relevant code snippet:
.
error_reporting(E_ALL);
.

I went to the link indicated in the documentation (<http://www.php.net/error_reporting>) to check out the various error-reporting options, and opted for the following, since it has been pointed out to me elsewhere that my spelling is subprime :) :

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

So, I guess that just about does it. In spite of what may seem like self-answered questions above, I am not at all sure about this, so if anybody before me has tried this, I would appreciate it if at least one of those somebodies took the trouble to look through this and see if I am way off base or not. For example, with my index.php file located on the unnamed_root_folder\highstreet\application path, will I be able to call up the blog.php file located in the unnamed_root_folder\highstreet\application\controllers folder, or should my index.php file be placed elsewhere, as I had to do with my main index.html file? As I indicated in an earlier posting, it is difficult for novices to know what it is that they need to know – to know what they don't know but should know.

Also, when I indicate above that I will only use "the PHP stuff" inside my webpages, I am making the assumption that I will only be using the CI program for the purpose of form validation. Can CI be used to make webpages? I have a three-column Javascript-augmented, CSS-based page which looks pretty snazzy, if I may say so myself, but I need to be able to handle user input where the user must choose a username to begin with, not unlike the login procedure here at CI that is required in order to post comments (on my site, however, I will be censoring, or moderating, to use a more perfumed word, user input, so input does not get posted directly... still, I need the username validation procedure, and therefore I will need a database to check entries against, which is what the CI setup looks as if it is designed to handle, among other tasks, no doubt).

Thanks for now.

buffalobill
#3

[eluser]maadmac[/eluser]
[quote author="buffalobill" date="1188888029"]
First of all, I presume that there is no way that one can call up a CI PHP file on one's PC, rather than on one's website? (I note that the URI (actually URL, I reckon) listed in the text-only tutorial (TT), reflects a webaddress). I have tried to access, on my mirror-image "website" on my PC, the files I created while following the TT, but it just didn't work. Trying to mimic the webaddress URL, I wrote the following URI in MS Word (it became a link), then clicked on the link to see if it would take me to the target file (blog.php in this case) in the mirror-image folder of my website located on my PC (no luck, by the way):
[/quote]

How on earth would anyone get anything done uploading to the remote server each time? You must have a local copy, my n00b friend.

Now, this is not strictly a CI question, it's a generic PHP one, but I'll take a stab at it anyway: PHP is a server-side scripting language, which means that it is installed and configured to work on a web server. Windows machines do not come with webservers installed -- if you want to develop locally with PHP, you need to install it locally.

Now, you can download and configure Apache/PHP yourself -- I've done it, and it's a nightmare getting it to work right. Much better is one of the one-click install packages:

XAMPP for Windows

XAMPP is my favorite. By default, once installed your local server will be available at:

Code:
http://localhost/

The only catch here is making sure you know what the path is to your local document folder. That is, you specify a folder on your hard disk, and Apache knows to serve any documents or scripts from that.

Ah, we all had to start somewhere...
#4

[eluser]buffalobill[/eluser]
See what I said about not knowing what one doesn't but should know?! Yet I, too, felt that there surely must be a way to work with this gizmo on one's own site, I just couldn't get a handle on it, which is why I tossed out the question. And thanks heaps for the tip concerning XAMPP. I found a good introductory piece on XAMPP on an IBM site
<http://www.ibm.com/developerworks/linux/library/l-xampp/?ca=dgr-lnxw07XAMPP >, and another one at the Apachefriends.org site <http://www.apachefriends.org/en/xampp-windows.html#1221> which developed, according to the IBM article, the XAMPP program (I mention all this for other n00bs like me who may run across this posting later). The Apachefriends.org site warns about using the XAMPP setup for anything but a development environment (production environment taboo), due to security considerations, although "slightly more security" can be obtained by using the XAMPP Security console (assigning passwords).

Hmm, in the index.php file – WHICH, by the way, is NOT located in the "system"\application folder as I suggested above, but rather, in the main CI folder one level above the "systems" folder – in reference to the bit about error reporting, the words "when your site goes live" were used. Combining the XAMPP warning about the development contra the production environment with the "when your site goes live" bit, does this mean that one develops the application partly on one's PC and partly on one's site – and I assume that when one clicks on the URIs of the type I have been mentioning here, using the index.php file betwixt the mydomain.com and the target file, that one doesn't really go to one's regular webpages like an outside visitor might (but not like an FTP does it either, i.e., looking only at filenames), but rather, one goes only to that piece of the programming application on which one is working, and to which the target file refers (a form, maybe) – and then when one is finished, one has, in the process, uploaded and tested – first on one's PC, then on one's site – a full-blown application (where full-blown is defined by the user's needs, like, in my example, form validation), at which time one cuts the XAMPP connection and "goes live"?

I'm just trying to get my mind around what I will be looking at – either on my PC's mirror site or on the website itself - when I eventually get XAMPP installed and up and running. You see, in my ideal DIY IT world (well, DIY with a little help from friends!) there would be a step-by-step section for novices which explained all of this, and which showed screen-capture images of the relevant dialog boxes, forms, etc. Heck, I would even pay for a good tutorial, just like I paid for my original HTML tutorial (PageTutor, with Joe Barta – Joe's a great guy with a fantastic ability to see the IT world from a novice's pedestrian perspective, but Joe doesn't have a PHP tutorial, alas!).

Thanks again,
buffalobill
#5

[eluser]thurting[/eluser]
I would suggest that you teach yourself some basic PHP before you start tinkering with CI. Furthermore, I suggest you do some light research on the Apache-MySQL-PHP stack before you begin to develop a site using PHP. Installing XAMPP is a first step (I prefer WAMP - use MAMP if you are on a Mac), but you need to understand the basics of what is happening under the hood before you move forward. Either look for some help online or get yourself a book on PHP/MySQL. Most books will walk you through setting up the AMP stack on your computer and explain to you the basics of the server side. I used to reference the following book a lot when I was first learning - make sure you get the latest edition if you do purchase it:

PHP-MySQL-Development

I would stay away from CI if you aren't familiar with PHP. CI is a framework built to aid in the development of PHP sites and will not be of much use if you are unfamiliar with the underlying language and the concepts surrounding it.

The steps you should probably take are:

1. Find some good reference websites or get a book
2. Set up a local development environment using Apache with PHP and MySQL installed
3. Learn PHP
4. Learn MySQL
5. Check out CI to ignite your PHP and MySQL development.
6. Profit.
#6

[eluser]maadmac[/eluser]
[quote author="buffalobill" date="1188898859"]
You see, in my ideal DIY IT world (well, DIY with a little help from friends!) there would be a step-by-step section for novices which explained all of this, and which showed screen-capture images of the relevant dialog boxes, forms, etc.
[/quote]

There are, bill, they're called 'books', you can find them in your local 'bookstore', or from amazon. All kinds of examples, explanations, and instructions for beginners... CI is just PHP, after all, and all of this has been exhaustively covered.

I'm totally with thurting on this, I would take his advice. CI is pretty advanced stuff -- it exists to make developers' live easier, to save the time from having to write a lot generic, repetive classes from scratch each time. But it's not really going to be useful to you until you've written one of these classes from scratch.

My suggestion, though, is this one:

PHP Solutions

I've read (or at least browsed) through virtually every major PHP 101 book out there, and I find this one to be head and shoulders above the rest for its clarity, attractiveness and utility. You can probably even find a used copy over at half.com for like 10 bucks. Or, go read it at Borders.

Also: thurting, you forgot one step. I didn't see 'steal underpants' anywhere in there.




Theme © iAndrew 2016 - Forum software by © MyBB