Jump to content

Home test server With Apache and php


danielkraus

Recommended Posts

As a suggestion, have you tried installing XAMPP? It is prepackaged and ready to go, and has a nice installer. Also has the mysql, apache, php and other components if you want too.http://www.apachefriends.org/en/xampp.htmlOnce you install a server though, you will be able to browse it by going to localhost , typing that in your browser. When you get more confident, look up about virtual hosts, so you can set a folder to go to say, currentwork/, or clientx/ to make life a bit easier for you.

Link to comment
Share on other sites

Thank You, I have downloaded WampServer and it works great! I looked into virtual servers but it seemed a little over my head at the moment. I did this to test my XMl XSLT fragments. I have a lot of content for the site I am working on and it seemed better for updates(which will happen often) to use XML/XSLT. I only need the XMl in one part of the page, do I need to use a scritpting language for XSLT fragments? Or will the XSLT take care of it? Thanx again

Link to comment
Share on other sites

If you still want to try and install the WAMP components manually, I suggest you follow Tanguay's tutorial. It even shows how to install the PHP XSL extension (it's actually as easy as installing any PHP extension).If you want to check out the results of XSLT transformations, you can also check it from the browsers' DOM inspectors. With Firefox for example, in the Web Developer toolbar you have View Source > View Genrated Source; In Opera you have a DOM Snapshot add-on, and for IE you have a DOM inspector (not as nifty as the source viewers of Opera and Firefox, but still good enough in most cases).Still, you're on the right track. I believe actually transforming XSLT on the server and having the result be directly parsed by the browser is the best way to debug XSLT.

Link to comment
Share on other sites

It even shows how to install the PHP XSL extension (it's actually as easy as installing any PHP extension).
I don't think 'as easy as' is quite the right phrase, I would go with 'as hard as' :) (ok, it isn't too bad, but I still much prefer using a packaged install, like XAMP, MAMP, or WAMP
Link to comment
Share on other sites

I don't think 'as easy as' is quite the right phrase, I would go with 'as hard as' :) (ok, it isn't too bad, but I still much prefer using a packaged install, like XAMP, MAMP, or WAMP
What's so hard about opening php.ini and uncommenting a single certain line?(If you have PHP installed as CGI, you don't even need to restart the web server)btw, MAMP? I never heared of that one before...
Link to comment
Share on other sites

To Jesdisciple -- I uninstalled before installing the WAMP. (sorry not sure how to quote tried the quote button but it seemed to take forever)Like I have said I am a beginner and have tons of questions. Is there a list of the functions of DOM? How they work and what they do? Kind of a A-Z of syntax? I would like to know how it works, not just copy and paste from somewhere else. My ultimate goal is to be able to code for others as well as my own ideas for web sites. I know I have a way to go, but I wish to make it as easy as possible for myslef and others to read the code, change it and make it more precise.To Boen Robot --- Thanx for the affirmation of me being on the right track, I have very few friends locally that are web designers and programmers making harder to find solutions to my questions. Thankfully this forum is here!!!!!

Link to comment
Share on other sites

Actually, look at the XSL extension. The XSLT extension is an older API for the older PHP4 using the older and less stable Salbotron XSLT processor. The API of the XSL extension is more flexible using the newer and more stable libxslt XSLT processor, but is only for PHP5.As for DOM, the W3Schools DOM reference is a good one. PHP also has one.The thing about DOM that you need to realize is that it represents the XML text equivalent, and that once you target a certain part of the XML source (that certain part being called "a node"), you can remove it, insert another node before or after it, or just change it's content.For example, when I do

$dom = new DOMDocument('1.0','UTF-8');

I essentially create an XML document looking like:

<?xml version="1.0" encoding="UTF-8"?>

later on, if I do

$rootElement = $dom->createElement('root', 'value of the root element');

I have created

<root>value of the root element</root>

and I store it in the $rootElement variable. THE ELEMENT IS NOT IN THE DOCUMENT JUST YET. It's just "in memory" ready to be inserted into the $dom variable, like so:

$dom->appendChild($rootElement);

with that last bit, $dom is now a DOM object representing:

<?xml version="1.0" encoding="UTF-8"?><root>value of the root element</root>

to see that, in PHP you do:

echo $dom->saveXML();

Read the W3Schools dom tutorial for more info. They're using JavaScript to teach it, but it's pretty easy to convert their examples and talks into PHP, as the same principals apply. For example:

xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName("title")[0];y=x.childNodes[0];txt=y.nodeValue;

Is the same as:

$xmlDoc = new DOMDocument;$xmlDoc->load('books.xml');$x = $xmlDoc->getElementsByTagName('title')->item(0);$y = $x->childNodes->item(0);$txt = $y->nodeValue;

And here's the killer (and why I personally learned DOM in PHP before I learned it in JavaScript) - you can simply echo or var_dump() the different variables to inspect what they have. To clear out the previous example, you might want to add the following last line in a PHP file:

var_dump($txt);

and change $txt to whatever variable you want to inspect.(you can also output multiple variables, but until you have a finer grasp of the things, I'd suggest you don't do that)

Link to comment
Share on other sites

Thank you both. It will take me a day or two to get through the code you listed boen. I think I understand what it is doing I just need a little time to get the nuts and bolts down. If I understand correctly, I can use DOM to pull from, change and move the information contained within the XML document to where I need it in the XHTML document. Correct? I would need 12 of my "nodes" per XHTML page and I can use the [#] predicates to specify this, I think. Its funny I am actually a content writer and have ventured into coding after a friend advised that it could help me, and I believe it has. Thanx again.

Link to comment
Share on other sites

If I understand correctly, I can use DOM to pull from, change and move the information contained within the XML document to where I need it in the XHTML document
... or any other place which is data dependant and which PHP could generate (eg. a programmatically generated image, SVG graphic, a form which's fields depend on that data, etc. etc.), yes.XSLT however is (I believe) far easier, reliable and readable way to make macro organizations of content. For example, I have per-page contents in XML files which are essentially XHTML. In XSLT, I create a common content and include that per-page content in it. PHP is used to find the appropriate XML file to match the XSLT against, and just outputs the result.And if plain XHTML is limiting, there are other ways to liven up the static XHTML (hint: XMLReader), though you might want to learn DOM before you get that far.
Link to comment
Share on other sites

I am going to jump in and apply what I know and see what happens. I have been using Dreamweaver as a learning tool. It has shown me or allowed me to see things I can use with immediate results that I can see. Would it be a bad idea to use Dreamweaver to help me with the XML? Or should I just use my Notepad to write the code?Oh yeah, I forgot to ask earlier but, what does API stand for? I have seen it all over the place and can't seem to figure out what it is. Thanx.

Link to comment
Share on other sites

I am going to jump in and apply what I know and see what happens. I have been using Dreamweaver as a learning tool. It has shown me or allowed me to see things I can use with immediate results that I can see. Would it be a bad idea to use Dreamweaver to help me with the XML? Or should I just use my Notepad to write the code?Oh yeah, I forgot to ask earlier but, what does API stand for? I have seen it all over the place and can't seem to figure out what it is. Thanx.
Stick with Dreamwaver's code view. Using WYSIWYG editors (Dreamwaver included) is a bad idea, but using such programs to help you edit and debug code is more than acceptable. Infact, it's reccomended, as it will save you a lot of time, while still keeping you in touch with what's under the hood.As said, API stands for Application Programming Interface. But I'm betting you still don't get what does it really mean, right? I know I didn't... think of an API as a set of classes for performing certain tasks. For example, DOM is an API (with classes like DOMDocument, DOMNode, etc.), the XSLTProcessor class is another API, etc.What really defines an API is the function and class names. DOM is one API because the method/function names ("getElementsByTagName", "saveXML") and properties names ("childNodes", "nodeValue") are the same in any language. Another set of methods and properties would have been another API.
Link to comment
Share on other sites

I haven't been using the WYSIWYG at all. I always use the code editor and check the layout and display in my browsers, IE, Mozilla, Safari etc.There are two options in Dreamweaver for XSLT. Fragments and entire page. I started an entire page document but the progarm generated a lot of code that I have not seen in any tutorial. It looks a lot like and XHTML document with extra code. Could I open an XML document and add the

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

and still get an XSL document?Basically, will the xsl info I add make the XML document an XSLT document?Thanx for the explanation of API, it makes a whole lot more sense now.

Link to comment
Share on other sites

XSLT is an XML based language, so I'd say that your statement is accurate.In the same fashion, if your XML starts with

<html xmlns="http://www.w3.org/1999/xhtml">

You're esentially storing XHTML. Storing your own set of tags and attributes (let's call them "MyML") would mean that you have MyML and so on. What makes a difference (and where the beauty of XML is) is how you parse it as.In other words, XSLT is read by XSLT processors in one way (they take the instructions to produce another XML or text), while the same document, if read by an XHTML parser will be interpreted in another way (the XHTML contents displayed, the unknown text nodes outputted non-formatted, and actual elements being ignored).For example, try to open the following XSLT file in Opera (do look at it in detail before and after you do so):

<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">	<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>	<xsl:template match="/">		<html>			<head>				<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>				<title>Title (the same for plain XHTML, and for post XSLT XHTML)</title>			</head>			<body>				<div>					<strong>This should be seen in both post XSLT XHTML and plain XHTML mode as a strong text.						<xsl:comment>And this should be a comment in post XSLT XTHML, but in plain XHTML mode, you'd see it as a strong text.</xsl:comment>					</strong>					<xsl:value-of select="'This non strong text should be visible only in post XSLT XHTML.'" />				</div>			</body>		</html>	</xsl:template></xsl:stylesheet>

and then try to apply the same XSLT file to any XML file.You'll see totally different results, because when you open XSLT (or any XML based document) in Opera, Opera tries to find XHTML elements, and it interprets them. As by the XHTML specification (I think...) it ignores the ones it doesn't understand, but it displays their contents.And when you use XSLT in an XSLT processor (eg. with PHP or by attaching an xml-stylesheet PI to another XML document), the XTHML which XSLT outputs is what you see on screen.It's one of those things that can be most easily understood if you use PHP for XSLT processing, since there isn't any "magic" - you have to do the steps manually, and thus see what interprets what.(and if you've had the thought of "what if MyML defined an element that's in XHTML already?" - that's what namespaces are for. In the example above, Opera recognizes XHTML elements thanks to the namespace declaration at the top, and XSLT processors finds its XSLT instructions thanks to the XSLT namespace above, which we've binded to the "xsl" prefix)P.S. I apologize for any headaches I may have caused you. I know first hand how much that "aha" moment really hurts the brain :) .

Link to comment
Share on other sites

It makes a bit more sense. I don't mind the headaches, it makes me think more clearly. :) I have some time alotted tommorrow to look at the php tutorials. I just took on a new freelance content job and my time is a little thin at the moment. But I have written sample xml and xslt documents that I will attempt to transform using php. I want to keep as much as I can server side. I figure I will start very simple and work into more complex or more involved coding, which I will need to get my content into the site where I want it.Can I still control the styles of my <h#> an <p> tags with CSS? I have a background image for the heading that will contain data from a tag in the XML document, a company name. And the <p> will contain the description, also data from the XML document. If not, its ok. I'll just need to learn a bit more. Currently the data or info is contained within a div and h respectively. Thanx.Almost forgot, when I add php to an XHTML document, even if it is just a few lines, I need to change the document to XXXXX.php instead of .html, correct?

Link to comment
Share on other sites

Almost forgot, when I add php to an XHTML document, even if it is just a few lines, I need to change the document to XXXXX.php instead of .html, correct?
Yes, that is the best way, however, if the Hosting Server allows it, you could also add an Application-type handler in your .htaccess file.
Link to comment
Share on other sites

Can I still control the styles of my <h#> an <p> tags with CSS? I have a background image for the heading that will contain data from a tag in the XML document, a company name. And the <p> will contain the description, also data from the XML document. If not, its ok. I'll just need to learn a bit more. Currently the data or info is contained within a div and h respectively. Thanx.
As long as you make sure the final XHTML document has those styles applied, yes.In other words, if you store CSS in XML source files, you need a way (DOM, XSLT) to extract that information and put it where it belongs (a "style" element or a new .css file), and (regardless of how you store the styling information) you need to make sure that you're styling your resulting document, not your source documents.
Almost forgot, when I add php to an XHTML document, even if it is just a few lines, I need to change the document to XXXXX.php instead of .html, correct?
As said, if the server allows it, you can make any file/extension be parsed by PHP. If not, yes. give it a PHP extension, and then if it's not (X)HTML content, make sure you add a proper Content-type header, like for example:
header('Content-type: application/xml');

for XML documents, etc.

Link to comment
Share on other sites

What's so hard about opening php.ini and uncommenting a single certain line?(If you have PHP installed as CGI, you don't even need to restart the web server)btw, MAMP? I never heared of that one before...
ok, so I was thinking installing apache/php in general can be a pain...and MAMP is just WAMP or LAMP except for OS X (the M is for mac if you haven't figured that out yet)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...