-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2018-05-30 AC: Adds all the code examples from the book.
* Adds all the code examples from the book Mastering the Faster Web: PHP, MySQL and JavaScript.
- Loading branch information
1 parent
469f0a4
commit aa2851f
Showing
115 changed files
with
55,538 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
# fasterweb | ||
Mastering the Faster Web | ||
<h1>Mastering the Faster Web with PHP, MySQL and JavaScript</h1> | ||
<p>Develop state of the art Web applications using the latest Web technologies</p> | ||
<p><br><br><br><br></p> | ||
<h2>Official code repository</h2> | ||
<p><br><br><br><br><br></p> | ||
<h3>Andrew Caya</h3> | ||
<p><br><br><br><br><br></p> | ||
<p><a href="https://commons.wikimedia.org/wiki/File:Packt_Logo.png#/media/File:Packt_Logo.png"><img src="https://upload.wikimedia.org/wikipedia/commons/b/bc/Packt_Logo.png" alt="Packt Logo"></a><br>By <a href="//commons.wikimedia.org/w/index.php?title=User:Dalston.nazareth&action=edit&redlink=1" class="new" title="User:Dalston.nazareth (page does not exist)">Dave Maclean</a> - <span class="int-own-work" lang="en">Own work</span>, <a href="https://creativecommons.org/licenses/by-sa/4.0" title="Creative Commons Attribution-Share Alike 4.0">CC BY-SA 4.0</a>, <a href="https://commons.wikimedia.org/w/index.php?curid=63328928">Link</a></p> | ||
<br> | ||
BIRMINGHAM - MUMBAI | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
################# | ||
### Chapter 1 ### | ||
################# | ||
git clone https://github.com/andrewscaya/fasterweb | ||
cd fasterweb/ | ||
docker run -it --rm -p 8181:80 -v ${PWD}/:/srv/fasterweb asclinux/linuxforphp-8.1:7.1.16-nts /bin/bash | ||
################# | ||
### Chapter 2 ### | ||
################# | ||
docker run -d --name influxdb -p 8086:8086 andrewscaya/influxdb | ||
docker network inspect bridge | ||
docker run --rm andrewscaya/telegraf -sample-config > telegraf.conf | ||
docker run --net=container:influxdb -v ${PWD}/telegraf.conf:/etc/telegraf/telegraf.conf:ro andrewscaya/telegraf | ||
docker run -d --name grafana -p 3000:3000 andrewscaya/grafana | ||
################# | ||
### Chapter 4 ### | ||
################# | ||
docker run -it --rm -p 8282:80 -v ${PWD}/:/srv/fasterweb asclinux/linuxforphp-8.1:7.0.29-zts /bin/bash | ||
docker exec -it $( docker ps -q | awk '{ print $1 }' ) /bin/bash | ||
################# | ||
### Chapter 9 ### | ||
################# | ||
docker run --rm -it -p 8383:80 asclinux/linuxforphp-8.1:src /bin/bash -c "cd ; wget -O tmp http://bit.ly/2jheBrr ; /bin/bash ./tmp 7.2.5 nts ; echo '<?php phpinfo();' > /srv/www/index.php ; /bin/bash" | ||
docker run -it -p 6082:6082 -p 8484:80 asclinux/linuxforphp-8.1:src /bin/bash | ||
docker network inspect bridge | ||
curl -v 172.17.0.3 | grep Forwarded | ||
curl -v https://linuxforphp.net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: 1 | ||
creator: xdebug 2.5.5 (PHP 7.1.3) | ||
cmd: /srv/www/index.php | ||
part: 1 | ||
positions: line | ||
|
||
events: Time | ||
|
||
fl=(1) php:internal | ||
fn=(1) php::phpinfo | ||
3 1221 | ||
|
||
fl=(2) /srv/www/index.php | ||
fn=(2) {main} | ||
|
||
summary: 12235718 | ||
|
||
1 12234496 | ||
cfl=(1) | ||
cfn=(1) | ||
calls=1 0 0 | ||
3 1221 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>It works!</title> | ||
</head> | ||
<body> | ||
<p>It works!</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
phpinfo(); | ||
|
||
$test = 'This is a test!'; | ||
|
||
$test1 = $test; | ||
|
||
echo $test1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
phpinfo(); |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
http://localhost/index.html | ||
http://localhost/index.html | ||
http://localhost/index.html | ||
http://localhost/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
http://localhost/index.php | ||
http://localhost/index.php | ||
http://localhost/index.php | ||
http://localhost/index.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Slow page</title> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style> | ||
/* Center the loader */ | ||
#se-pre-con { | ||
position: absolute; | ||
left: 50%; | ||
top: 50%; | ||
z-index: 1; | ||
width: 150px; | ||
height: 150px; | ||
margin: -75px 0 0 -75px; | ||
border: 16px solid #f3f3f3; | ||
border-radius: 50%; | ||
border-top: 16px solid #3498db; | ||
width: 120px; | ||
height: 120px; | ||
-webkit-animation: spin 2s linear infinite; | ||
animation: spin 2s linear infinite; | ||
} | ||
|
||
@-webkit-keyframes spin { | ||
0% { -webkit-transform: rotate(0deg); } | ||
100% { -webkit-transform: rotate(360deg); } | ||
} | ||
|
||
@keyframes spin { | ||
0% { transform: rotate(0deg); } | ||
100% { transform: rotate(360deg); } | ||
} | ||
|
||
/* Add animation to "page content" */ | ||
.animate-bottom { | ||
position: relative; | ||
-webkit-animation-name: animatebottom; | ||
-webkit-animation-duration: 1s; | ||
animation-name: animatebottom; | ||
animation-duration: 1s | ||
} | ||
|
||
@-webkit-keyframes animatebottom { | ||
from { bottom:-100px; opacity:0 } | ||
to { bottom:0px; opacity:1 } | ||
} | ||
|
||
@keyframes animatebottom { | ||
from{ bottom:-100px; opacity:0 } | ||
to{ bottom:0; opacity:1 } | ||
} | ||
|
||
#contents { | ||
display: none; | ||
text-align: left; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body onload="myAnimatedAjax()" style="margin:0;"> | ||
|
||
<div id="se-pre-con"></div> | ||
|
||
<div id="contents"></div> | ||
|
||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> | ||
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.2/modernizr.js"></script> | ||
|
||
<script type="text/javascript"> | ||
|
||
jQuery.ajaxSetup({ | ||
beforeSend: function() { | ||
$("#contents").html("Loading page... One moment please...").toggle(); | ||
}, | ||
complete: function(){ | ||
$("#se-pre-con").fadeOut("slow"); //toggle visibility: off | ||
}, | ||
success: function(result) { | ||
$("#contents").html(result); | ||
} | ||
}); | ||
|
||
function myAnimatedAjax() { | ||
var myVar = setTimeout(animatedAjax, 500); | ||
} | ||
|
||
function animatedAjax() { | ||
$.ajax({ | ||
type: "GET", | ||
url: "/chap10_slow_before.php" | ||
}); | ||
} | ||
|
||
</script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
// chap10_slow_before.php | ||
|
||
sleep(5); | ||
|
||
echo 'The original page loads very slowly...'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>It works!</title> | ||
</head> | ||
<body> | ||
<p>It works!</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
phpinfo(); | ||
|
||
$test = 'This is a test!'; | ||
|
||
$test1 = $test; | ||
|
||
echo $test1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
phpinfo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
; .blackfire.travis.ini | ||
[blackfire] | ||
|
||
server-id=BLACKFIRE_SERVER_ID | ||
server-token=BLACKFIRE_SERVER_TOKEN | ||
client-id=BLACKFIRE_CLIENT_ID | ||
client-token=BLACKFIRE_CLIENT_TOKEN | ||
endpoint=https://blackfire.io/ | ||
collector=https://blackfire.io/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
tests: | ||
"Pages should be fast enough": | ||
path: "/.*" # run the assertions for all HTTP requests | ||
assertions: | ||
- "main.wall_time < 10ms" # wall clock time is less than 10ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
language: php | ||
|
||
matrix: | ||
include: | ||
- php: 5.6 | ||
- php: 7.0 | ||
env: BLACKFIRE=on | ||
|
||
sudo: false | ||
|
||
cache: | ||
- $HOME/.composer/cache/files | ||
|
||
before_install: | ||
- if [[ "$BLACKFIRE" = "on" ]]; then | ||
openssl aes-256-cbc -K [ENCRYPT_KEY_HERE] -iv [ENCRYPT_IV_HERE] -in .blackfire.travis.ini.enc -out ~/.blackfire.ini -d | ||
curl -L https://blackfire.io/api/v1/releases/agent/linux/amd64 | tar zxpf - | ||
chmod 755 agent && ./agent --config=~/.blackfire.ini --socket=unix:///tmp/blackfire.sock & | ||
fi | ||
|
||
install: | ||
- travis_retry composer install | ||
|
||
before_script: | ||
- phpenv config-rm xdebug.ini || true | ||
- if [[ "$BLACKFIRE" = "on" ]]; then | ||
curl -L https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION . PHP_MINOR_VERSION;")-zts | tar zxpf - | ||
echo "extension=$(pwd)/$(ls blackfire-*.so | tr -d '[[:space:]]')" > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/blackfire.ini | ||
echo "blackfire.agent_socket=unix:///tmp/blackfire.sock" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/blackfire.ini | ||
fi | ||
|
||
script: | ||
- phpunit |
Oops, something went wrong.