public function getFileBuilder() { $fileBuilder = new FileBuilder(); $fileBuilder->addFileContents('index.php', <<<EOF <!-- read from the toys.json file and set the \$toys variable --> <?php foreach (\$toys as \$toy) { ?> <h3><?php echo \$toy['name']; ?></h3> <h4><?php echo \$toy['color']; ?></h4> <?php } ?> EOF ); $fileBuilder->setEntryPointFilename('index.php'); $fileBuilder->addFileContents('toys.json', <<<EOF [ { "name": "Bacon Bone", "toy_color": "Bacon-colored" }, { "name": "Tennis Ball", "toy_color": "Yellow" }, { "name": "Frisbee", "toy_color": "Red" } ] EOF ); return $fileBuilder; }
public function getFileBuilder() { $fileBuilder = new FileBuilder(); $fileBuilder->addFileContents('index.php', <<<EOF <?php \$contents = file_get_contents('toys.json'); \$toys = json_decode(\$contents, true); ?> <?php foreach (\$toys as \$toy) { ?> <h3><?php echo \$toy['name']; ?></h3> <h4><?php echo \$toy['color']; ?></h4> <?php } ?> EOF ); $fileBuilder->setEntryPointFilename('index.php'); $fileBuilder->addFileContents('toys.json', <<<EOF [ { "name": "Bacon Bone" }, { "name": "Tennis Ball", "color": "Yellow" }, { "name": "Frisbee", "color": "Red" } ] EOF ); return $fileBuilder; }
public function getFileBuilder() { $fileBuilder = new FileBuilder(); $fileBuilder->addFileContents('aboutUs.php', <<<EOF <!-- require the header here --> <h1>About Us</h1> <p> We're just a couple of <mark>crazy</mark> cats with a dog-gone good idea! </p> <address> <strong>AirpupNMeow</strong><br> 555 Main Street<br> San Francisco, CA 94107<br> <abbr title="Phone">P:</abbr> (123) 456-7890 </address> <!-- require the footer here --> EOF ); $fileBuilder->setEntryPointFilename('aboutUs.php'); $fileBuilder->addFileContents('index.php', <<<EOF <?php \$airpupTagLine = 'We luv puppies!'; ?> <!-- HEADER CODE STARTS HERE --> <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" /> </head> <body> <div class="container"> <!-- HEADER CODE ENDS HERE --> <h1>Welcome to AirPupNMeow.com!</h1> <h3><?php echo \$airpupTagLine; ?></h3> <!-- FOOTER CODE STARTS HERE --> \t<footer> © 2015 AirPupNMeow.com \t</footer> \t</div> </body> </html> <!-- FOOTER CODE STARTS HERE --> EOF ); $fileBuilder->addFileContents('layout/header.php', <<<EOF <!-- Move the HEADER code into here --> EOF ); $fileBuilder->addFileContents('layout/footer.php', <<<EOF <!-- Move the FOOTER code into here --> EOF ); return $fileBuilder; }
public function getFileBuilder() { $fileBuilder = new FileBuilder(); $fileBuilder->addFileContents('new_toy.php', <<<EOF <?php require 'functions.php'; \$name = \$_POST['name']; \$description = \$_POST['description']; \$toys = get_great_pet_toys(); \$toys[] = array('name' => \$name, 'description' => \$description); \$json = json_encode(\$toys, JSON_PRETTY_PRINT); file_put_contents('toys.json', \$json); ?> <form action="/new_toy.php" method="POST"> <input type="text" name="toy_name" /> <textarea name="description"></textarea> <button type="submit">Add toy</button> </form> EOF ); $fileBuilder->setEntryPointFilename('new_toy.php'); $fileBuilder->addFileContents('functions.php', <<<EOF <?php function get_great_pet_toys() { \$contents = file_get_contents('toys.json'); \$toys = json_decode(\$contents, true); return \$toys; } EOF ); $fileBuilder->addFileContents('toys.json', <<<EOF [ { "name": "Bacon Bone", "description": "What could be better?" }, { "name": "Tennis Ball", "description": "Throw, fetch, throw, fetch, throw, fetch..." }, { "name": "Frisbee", "description": "Go Deep!" } ] EOF ); return $fileBuilder; }
public function getFileBuilder() { $fileBuilder = new FileBuilder(); $fileBuilder->addFileContents('aboutUs.php', <<<EOF EOF ); $fileBuilder->setEntryPointFilename('aboutUs.php'); $fileBuilder->addFileContents('about.php', <<<EOF <h1>Yea! About us!</h1> EOF ); return $fileBuilder; }
public function getFileBuilder() { $fileBuilder = new FileBuilder(); $fileBuilder->addFileContents('index.php', <<<EOF <h2> <!-- print the variable here --> </h2> EOF ); $fileBuilder->addFileContents('bootstrap.php', <<<EOF <?php \$whatILove = "Puppies"; require("index.php"); EOF ); $fileBuilder->setEntryPointFilename('bootstrap.php'); return $fileBuilder; }
public function getFileBuilder() { $fileBuilder = new FileBuilder(); $fileBuilder->addFileContents('index.php', <<<EOF <?php function get_great_pet_toys() { \$contents = file_get_contents('toys.json'); \$toys = json_decode(\$contents, true); return \$toys; } \$toys = get_great_pet_toys(); ?> <?php foreach (\$toys as \$toy) { ?> <h3><?php echo \$toy['name']; ?></h3> <h4><?php echo \$toy['color']; ?></h4> <?php } ?> EOF ); $fileBuilder->setEntryPointFilename('index.php'); $fileBuilder->addFileContents('lib/functions.php', <<<EOF <!-- put the get_great_pet_toys() function here --> EOF ); $fileBuilder->addFileContents('toys.json', <<<EOF [ { "name": "Bacon Bone", "color": "Bacon Colored" }, { "name": "Tennis Ball", "color": "Yellow" }, { "name": "Frisbee", "color": "Multiple Colors" } ] EOF ); return $fileBuilder; }
public function getFileBuilder() { $fileBuilder = new FileBuilder(); $fileBuilder->addFileContents('index.php', <<<EOF <?php \$contents = file_get_contents('toys.json'); \$toys = json_decode(\$contents, true); ?> <?php foreach (\$toys as \$toy) { ?> <h3><?php echo \$toy['name']; ?></h3> <h4> <?php if (array_key_exists('color', \$toy) && \$toy['color'] = 'surprise') { echo 'Surprise Color!'; } elseif !array_key_exists('color', \$toy) { echo 'no color'; } else { echo \$toy['color']; } ?> </h4> <?php } ?> EOF ); $fileBuilder->setEntryPointFilename('index.php'); $fileBuilder->addFileContents('toys.json', <<<EOF [ { "name": "Bacon Bone" }, { "name": "Tennis Ball", "color": "Yellow" }, { "name": "Frisbee", "color": "surprise" } ] EOF ); return $fileBuilder; }