mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-06 14:06:34 +02:00
Verify link consistency - round 1
- Verify that all named links at the bottom of a post are in use, otherwise either remove or add link in post - if the post uses named links, try and make sure all links in the post are in that style - ensure logical order for the named links at the bottom
This commit is contained in:
@@ -12,9 +12,8 @@ There are multiple ways to install PHP on OS X.
|
|||||||
|
|
||||||
### Install PHP via Homebrew
|
### Install PHP via Homebrew
|
||||||
|
|
||||||
[Homebrew](http://brew.sh/) is a powerful package manager for OS X, which can help you install PHP and various
|
[Homebrew] is a powerful package manager for OS X, which can help you install PHP and various extensions easily.
|
||||||
extensions easily. [Homebrew PHP] is a repository that contains PHP-related "formulae" for Homebrew, and will let you
|
[Homebrew PHP] is a repository that contains PHP-related "formulae" for Homebrew, and will let you install PHP.
|
||||||
install PHP.
|
|
||||||
|
|
||||||
At this point, you can install `php53`, `php54`, `php55` or `php56` using the `brew install` command, and switch
|
At this point, you can install `php53`, `php54`, `php55` or `php56` using the `brew install` command, and switch
|
||||||
between them by modifying your `PATH` variable.
|
between them by modifying your `PATH` variable.
|
||||||
@@ -27,8 +26,8 @@ applications/projects require different versions of PHP, and you are not using v
|
|||||||
### Compile from Source
|
### Compile from Source
|
||||||
|
|
||||||
Another option that gives you control over the version of PHP you install, is to [compile it yourself][mac-compile].
|
Another option that gives you control over the version of PHP you install, is to [compile it yourself][mac-compile].
|
||||||
In that case be sure to have installed either Xcode or Apple's substitute ["Command Line Tools for XCode"]
|
In that case be sure to have installed either [Xcode][xcode-gcc-substitution] or Apple's substitute
|
||||||
downloadable from Apple's Mac Developer Center.
|
["Command Line Tools for XCode"] downloadable from Apple's Mac Developer Center.
|
||||||
|
|
||||||
### All-in-One Installers
|
### All-in-One Installers
|
||||||
|
|
||||||
@@ -38,10 +37,9 @@ you and tie them all together, but ease of setup comes with a trade-off of flexi
|
|||||||
|
|
||||||
[Homebrew]: http://brew.sh/
|
[Homebrew]: http://brew.sh/
|
||||||
[Homebrew PHP]: https://github.com/Homebrew/homebrew-php#installation
|
[Homebrew PHP]: https://github.com/Homebrew/homebrew-php#installation
|
||||||
|
[phpbrew]: https://github.com/phpbrew/phpbrew
|
||||||
[mac-compile]: http://php.net/install.macosx.compile
|
[mac-compile]: http://php.net/install.macosx.compile
|
||||||
[xcode-gcc-substitution]: https://github.com/kennethreitz/osx-gcc-installer
|
[xcode-gcc-substitution]: https://github.com/kennethreitz/osx-gcc-installer
|
||||||
|
|
||||||
["Command Line Tools for XCode"]: https://developer.apple.com/downloads
|
["Command Line Tools for XCode"]: https://developer.apple.com/downloads
|
||||||
[mamp-downloads]: http://www.mamp.info/en/downloads/
|
[mamp-downloads]: http://www.mamp.info/en/downloads/
|
||||||
[phpbrew]: https://github.com/phpbrew/phpbrew
|
|
||||||
[xampp]: http://www.apachefriends.org/en/xampp.html
|
[xampp]: http://www.apachefriends.org/en/xampp.html
|
||||||
|
@@ -20,10 +20,10 @@ FastCGI built in and ready to go, you just need to configure PHP as a handler. F
|
|||||||
there is a [dedicated area on iis.net][php-iis] for PHP.
|
there is a [dedicated area on iis.net][php-iis] for PHP.
|
||||||
|
|
||||||
[php-downloads]: http://windows.php.net
|
[php-downloads]: http://windows.php.net
|
||||||
[phpmanager]: http://phpmanager.codeplex.com/
|
|
||||||
[wpi]: http://www.microsoft.com/web/downloads/platform.aspx
|
[wpi]: http://www.microsoft.com/web/downloads/platform.aspx
|
||||||
[zsce]: http://www.zend.com/en/products/server-ce/
|
[zsce]: http://www.zend.com/en/products/server-ce/
|
||||||
[xampp]: http://www.apachefriends.org/en/xampp.html
|
[xampp]: http://www.apachefriends.org/en/xampp.html
|
||||||
[easyphp]: http://www.easyphp.org/
|
[easyphp]: http://www.easyphp.org/
|
||||||
[wamp]: http://www.wampserver.com/en/
|
[wamp]: http://www.wampserver.com/en/
|
||||||
|
[phpmanager]: http://phpmanager.codeplex.com/
|
||||||
[php-iis]: http://php.iis.net/
|
[php-iis]: http://php.iis.net/
|
||||||
|
@@ -47,15 +47,17 @@ available as `__call()` and `__callStatic()`.
|
|||||||
|
|
||||||
* [Read about Magic Methods][magic-methods]
|
* [Read about Magic Methods][magic-methods]
|
||||||
* [Read about Reflection][reflection]
|
* [Read about Reflection][reflection]
|
||||||
|
* [Read about Overloading][overloading]
|
||||||
|
|
||||||
|
|
||||||
[namespaces]: http://php.net/language.namespaces
|
|
||||||
[overloading]: http://php.net/language.oop5.overloading
|
|
||||||
[oop]: http://php.net/language.oop5
|
[oop]: http://php.net/language.oop5
|
||||||
|
[traits]: http://php.net/language.oop5.traits
|
||||||
[anonymous-functions]: http://php.net/functions.anonymous
|
[anonymous-functions]: http://php.net/functions.anonymous
|
||||||
[closure-class]: http://php.net/class.closure
|
[closure-class]: http://php.net/class.closure
|
||||||
|
[closures-rfc]: https://wiki.php.net/rfc/closures
|
||||||
[callables]: http://php.net/language.types.callable
|
[callables]: http://php.net/language.types.callable
|
||||||
|
[call-user-func-array]: http://php.net/function.call-user-func-array
|
||||||
[magic-methods]: http://php.net/language.oop5.magic
|
[magic-methods]: http://php.net/language.oop5.magic
|
||||||
[reflection]: http://php.net/intro.reflection
|
[reflection]: http://php.net/intro.reflection
|
||||||
[traits]: http://php.net/language.oop5.traits
|
[overloading]: http://php.net/language.oop5.overloading
|
||||||
[call-user-func-array]: http://php.net/function.call-user-func-array
|
|
||||||
[closures-rfc]: https://wiki.php.net/rfc/closures
|
|
||||||
|
@@ -58,6 +58,6 @@ Hello, world
|
|||||||
[cli-options]: http://php.net/features.commandline.options
|
[cli-options]: http://php.net/features.commandline.options
|
||||||
[argc]: http://php.net/reserved.variables.argc
|
[argc]: http://php.net/reserved.variables.argc
|
||||||
[argv]: http://php.net/reserved.variables.argv
|
[argv]: http://php.net/reserved.variables.argv
|
||||||
|
[exit-codes]: http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
|
||||||
[php-cli]: http://php.net/features.commandline
|
[php-cli]: http://php.net/features.commandline
|
||||||
[php-cli-windows]: http://php.net/install.windows.commandline
|
[php-cli-windows]: http://php.net/install.windows.commandline
|
||||||
[exit-codes]: http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
|
|
||||||
|
@@ -40,6 +40,6 @@ stand-alone xdebug GUI for Mac.
|
|||||||
* [Learn more about XDebug][xdebug-docs]
|
* [Learn more about XDebug][xdebug-docs]
|
||||||
* [Learn more about MacGDBp][macgdbp-install]
|
* [Learn more about MacGDBp][macgdbp-install]
|
||||||
|
|
||||||
[xdebug-docs]: http://xdebug.org/docs/
|
|
||||||
[xdebug-install]: http://xdebug.org/docs/install
|
[xdebug-install]: http://xdebug.org/docs/install
|
||||||
|
[xdebug-docs]: http://xdebug.org/docs/
|
||||||
[macgdbp-install]: http://www.bluestatic.org/software/macgdbp/
|
[macgdbp-install]: http://www.bluestatic.org/software/macgdbp/
|
||||||
|
@@ -5,8 +5,8 @@ anchor: further_reading
|
|||||||
|
|
||||||
## Further Reading {#further_reading_title}
|
## Further Reading {#further_reading_title}
|
||||||
|
|
||||||
- [Learning about Dependency Injection and PHP](http://ralphschindler.com/2011/05/18/learning-about-dependency-injection-and-php)
|
* [Learning about Dependency Injection and PHP](http://ralphschindler.com/2011/05/18/learning-about-dependency-injection-and-php)
|
||||||
- [What is Dependency Injection?](http://fabien.potencier.org/article/11/what-is-dependency-injection)
|
* [What is Dependency Injection?](http://fabien.potencier.org/article/11/what-is-dependency-injection)
|
||||||
- [Dependency Injection: An analogy](http://mwop.net/blog/260-Dependency-Injection-An-analogy.html)
|
* [Dependency Injection: An analogy](http://mwop.net/blog/260-Dependency-Injection-An-analogy.html)
|
||||||
- [Dependency Injection: Huh?](http://net.tutsplus.com/tutorials/php/dependency-injection-huh/)
|
* [Dependency Injection: Huh?](http://net.tutsplus.com/tutorials/php/dependency-injection-huh/)
|
||||||
- [Dependency Injection as a tool for testing](http://philipobenito.github.io/dependency-injection-as-a-tool-for-testing/)
|
* [Dependency Injection as a tool for testing](http://philipobenito.github.io/dependency-injection-as-a-tool-for-testing/)
|
||||||
|
@@ -15,18 +15,18 @@ same drivers. You'll need to learn a brand new API for each database — and
|
|||||||
|
|
||||||
## MySQL Extension
|
## MySQL Extension
|
||||||
|
|
||||||
The [mysql] extension for PHP is no longer in active development, and is [officially deprecated as of PHP 5.5.0],
|
The [mysql] extension for PHP is no longer in active development, and is [officially deprecated as of PHP 5.5.0]
|
||||||
meaning that it will be removed within the next few releases. If you are using any functions that start with `mysql_*`
|
[mysql_deprecated], meaning that it will be removed within the next few releases. If you are using any functions that
|
||||||
such as `mysql_connect()` and `mysql_query()` in your applications then these will simply not be available in later
|
start with `mysql_*` such as `mysql_connect()` and `mysql_query()` in your applications then these will simply not be
|
||||||
versions of PHP. This means you will be faced with a rewrite at some point down the line, so the best option is to
|
available in later versions of PHP. This means you will be faced with a rewrite at some point down the line, so the
|
||||||
replace mysql usage with [mysqli] or [PDO] in your applications within your own development schedules so you won't be
|
best option is to replace mysql usage with [mysqli] or [PDO] in your applications within your own development schedules
|
||||||
rushed later on.
|
so you won't be rushed later on.
|
||||||
|
|
||||||
**If you are starting from scratch then absolutely do not use the [mysql] extension: use the [MySQLi extension][mysqli],
|
**If you are starting from scratch then absolutely do not use the [mysql] extension: use the [MySQLi extension][mysqli],
|
||||||
or use [PDO].**
|
or use [PDO].**
|
||||||
|
|
||||||
* [PHP: Choosing an API for MySQL](http://php.net/mysqlinfo.api.choosing)
|
* [PHP: Choosing an API for MySQL][mysql_api]
|
||||||
* [PDO Tutorial for MySQL Developers](http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers)
|
* [PDO Tutorial for MySQL Developers][pdo4mysql_devs]
|
||||||
|
|
||||||
## PDO Extension
|
## PDO Extension
|
||||||
|
|
||||||
@@ -66,10 +66,9 @@ $pdo->query("SELECT name FROM users WHERE id = " . $_GET['id']); // <-- NO!
|
|||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
This is terrible code. You are inserting a raw query parameter into a SQL query. This will get you hacked in a
|
This is terrible code. You are inserting a raw query parameter into a SQL query. This will get you hacked in a
|
||||||
heartbeat, using a practice called [SQL Injection](http://wiki.hashphp.org/Validation). Just imagine if a hacker
|
heartbeat, using a practice called [SQL Injection]. Just imagine if a hacker passes in an inventive `id` parameter by
|
||||||
passes in an inventive `id` parameter by calling a URL like `http://domain.com/?id=1%3BDELETE+FROM+users`. This will
|
calling a URL like `http://domain.com/?id=1%3BDELETE+FROM+users`. This will set the `$_GET['id']` variable to `1;DELETE
|
||||||
set the `$_GET['id']` variable to `1;DELETE FROM users` which will delete all of your users! Instead, you should
|
FROM users` which will delete all of your users! Instead, you should sanitize the ID input using PDO bound parameters.
|
||||||
sanitize the ID input using PDO bound parameters.
|
|
||||||
|
|
||||||
{% highlight php %}
|
{% highlight php %}
|
||||||
<?php
|
<?php
|
||||||
@@ -92,10 +91,13 @@ unless of course you are using persistent connections.
|
|||||||
|
|
||||||
* [Learn about PDO connections]
|
* [Learn about PDO connections]
|
||||||
|
|
||||||
|
|
||||||
|
[mysql_deprecated]: http://php.net/migration55.deprecated
|
||||||
|
[mysql_api]: http://php.net/mysqlinfo.api.choosing
|
||||||
|
[pdo4mysql_devs]: http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers
|
||||||
|
[SQL Injection]: http://wiki.hashphp.org/Validation
|
||||||
[Learn about PDO]: http://php.net/book.pdo
|
[Learn about PDO]: http://php.net/book.pdo
|
||||||
[Learn about PDO connections]: http://php.net/pdo.connections
|
[Learn about PDO connections]: http://php.net/pdo.connections
|
||||||
[officially deprecated as of PHP 5.5.0]: http://php.net/migration55.deprecated
|
|
||||||
[SQL Injection]: http://wiki.hashphp.org/Validation
|
|
||||||
|
|
||||||
[pdo]: http://php.net/pdo
|
[pdo]: http://php.net/pdo
|
||||||
[mysql]: http://php.net/mysql
|
[mysql]: http://php.net/mysql
|
||||||
|
@@ -95,6 +95,7 @@ real problem if you ever want to [unit-test](/#unit-testing) your application.
|
|||||||
[PHPBridge] have a great resource called [Creating a Data Class] which covers a very similar topic, and is great for
|
[PHPBridge] have a great resource called [Creating a Data Class] which covers a very similar topic, and is great for
|
||||||
developers just getting used to the concept of interacting with databases.
|
developers just getting used to the concept of interacting with databases.
|
||||||
|
|
||||||
|
|
||||||
[MVC]: http://code.tutsplus.com/tutorials/mvc-for-noobs--net-10488
|
[MVC]: http://code.tutsplus.com/tutorials/mvc-for-noobs--net-10488
|
||||||
[PHPBridge]: http://phpbridge.org/
|
[PHPBridge]: http://phpbridge.org/
|
||||||
[Creating a Data Class]: http://phpbridge.org/intro-to-php/creating_a_data_class
|
[Creating a Data Class]: http://phpbridge.org/intro-to-php/creating_a_data_class
|
||||||
|
@@ -6,9 +6,9 @@ anchor: databases_abstraction_layers
|
|||||||
|
|
||||||
## Abstraction Layers {#databases_abstraction_layers_title}
|
## Abstraction Layers {#databases_abstraction_layers_title}
|
||||||
|
|
||||||
Many frameworks provide their own abstraction layer which may or may not sit on top of PDO. These will often emulate
|
Many frameworks provide their own abstraction layer which may or may not sit on top of [PDO][1]. These will often
|
||||||
features for one database system that is missing from another by wrapping your queries in PHP methods, giving you
|
emulate features for one database system that is missing from another by wrapping your queries in PHP methods, giving
|
||||||
actual database abstraction instead of just the connection abstraction that PDO provides. This will of course add a
|
you actual database abstraction instead of just the connection abstraction that PDO provides. This will of course add a
|
||||||
little overhead, but if you are building a portable application that needs to work with MySQL, PostgreSQL and SQLite
|
little overhead, but if you are building a portable application that needs to work with MySQL, PostgreSQL and SQLite
|
||||||
then a little overhead will be worth it the sake of code cleanliness.
|
then a little overhead will be worth it the sake of code cleanliness.
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@ installed in any application you like:
|
|||||||
* [Propel][7]
|
* [Propel][7]
|
||||||
* [ZF2 Db][4]
|
* [ZF2 Db][4]
|
||||||
|
|
||||||
|
|
||||||
[1]: http://php.net/book.pdo
|
[1]: http://php.net/book.pdo
|
||||||
[2]: http://www.doctrine-project.org/projects/dbal.html
|
[2]: http://www.doctrine-project.org/projects/dbal.html
|
||||||
[4]: http://packages.zendframework.com/docs/latest/manual/en/index.html#zend-db
|
[4]: http://packages.zendframework.com/docs/latest/manual/en/index.html#zend-db
|
||||||
|
@@ -83,5 +83,5 @@ defined to capture variables in scope and access them later when the anonymous f
|
|||||||
* [Read about dynamically invoking functions with `call_user_func_array`][call-user-func-array]
|
* [Read about dynamically invoking functions with `call_user_func_array`][call-user-func-array]
|
||||||
|
|
||||||
[anonymous-functions]: http://php.net/functions.anonymous
|
[anonymous-functions]: http://php.net/functions.anonymous
|
||||||
[call-user-func-array]: http://php.net/function.call-user-func-array
|
|
||||||
[closures-rfc]: https://wiki.php.net/rfc/closures
|
[closures-rfc]: https://wiki.php.net/rfc/closures
|
||||||
|
[call-user-func-array]: http://php.net/function.call-user-func-array
|
||||||
|
Reference in New Issue
Block a user