forked from codeguy/php-the-right-way
-
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.
Merge branch 'gh-pages' of github.com:codeguy/php-the-right-way into …
…gh-pages
- Loading branch information
Showing
10 changed files
with
138 additions
and
32 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
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
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,3 +1,10 @@ | ||
# Dependency Management | ||
|
||
There are a ton of PHP libraries, frameworks, and components to choose from. Your project will likely use several of them — these are project dependencies. Until recently, PHP did not have a good way to manage these project dependencies. Even if you managed them manually, you still had to worry about autoloaders. No more. | ||
|
||
Currently there are two major package management systems for PHP - Composer and PEAR. Which one is right for you? The answer is both. | ||
|
||
* Use **Composer** when managing dependencies for a single project. | ||
* Use **PEAR** when managing dependencies for PHP as a whole on your system. | ||
|
||
In general, Composer packages will be available only in the projects that you explicitly specify whereas a PEAR package would be available to all of your PHP projects. While PEAR might sound like the easier approach at first glance, there are advantages to using a project-by-project approach to your dependencies. |
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
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
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
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,44 @@ | ||
--- | ||
isChild: true | ||
--- | ||
|
||
## Object Caching | ||
|
||
There are times when it can be beneficial to cache individual objects in your code, such as with data that is expensive | ||
to get or database calls where the result is unlikely to change. You can use object caching software to hold these | ||
pieces of data in memory for extremely fast access later on. If you save these items to a data store after you retrieve | ||
them, then pull them directly from the cache for following requests you can gain a significant improvement in | ||
performance as well as reduce the load on your database servers. | ||
|
||
Many of the popular bytecode caching solutions let you cache custom data as well, so there's even more reason to take | ||
advantage of them. APC, XCache, and WinCache all provide APIs to save data from your PHP code to their memory cache. | ||
|
||
The most commonly used memory object caching systems are APC and memcached. APC is an excellent choice for object | ||
caching, it includes a simple API for adding your own data to its memory cache and is very easy to setup and use. The | ||
one real limitation of APC is that it is tied to the server it's installed on. Memcached on the other hand is installed | ||
as a separate service and can be accessed across the network, meaning that you can store objects in a hyper-fast data | ||
store in a central location and many different systems can pull from it. | ||
|
||
In a networked configuration APC will usually outperform memcached in terms of access speed, but memcached will be able | ||
to scale up faster and further. If you do not expect to have multiple servers running your application, or do not need | ||
the extra features that memcached offers then APC is probably your best choice for object caching. | ||
|
||
Example logic using APC: | ||
|
||
{% highlight php %} | ||
<?php | ||
$data = apc_fetch('expensive_data'); | ||
if (!$data) | ||
{ | ||
$data = get_expensive_data(); | ||
apc_store('expensive_data', $data); | ||
} | ||
{% endhighlight %} | ||
Learn more about popular object caching systems: | ||
* [APC Functions](http://php.net/manual/en/ref.apc.php) | ||
* [Memcached](http://memcached.org/) | ||
* [Redis](http://redis.io/) | ||
* [XCache APIs](http://xcache.lighttpd.net/wiki/XcacheApi) | ||
* [WinCache Functions](http://www.php.net/manual/en/ref.wincache.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
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,24 @@ | ||
# Community | ||
|
||
The PHP community is as diverse as it is large, and it's members are ready and willing to support new PHP programmers. You should consider joining your local PHP user group (PUG) or attending larger PHP conferences to learn more about the best practices shown here. You can also hang out on IRC in the #phpc channel on irc.freenode.com and follow the [@phpc][phpc-twitter] twitter account. Get out there, meet new developers, learn new topics and, above all, make new friends. | ||
|
||
[Read the Official PHP Events Calendar][php-calendar] | ||
|
||
## PHP User Groups | ||
|
||
If you live in a larger city, odds are there's a PHP user group nearby. Although there's not yet an official list of PUGs, you can easily find your local PUG by searching on [Google][google] or [Meetup.com][meetup]. If you live in a smaller town, there may not be a local PUG; if that's the case, start one! | ||
|
||
[Read about User Groups on the PHP Wiki][php-wiki] | ||
|
||
## PHP Conferences | ||
|
||
The PHP community also hosts larger regional and national conferences in many countries around the world. Well-known members of the PHP community usually speak at these larger events, so it's a great opportunity to learn directly from industry leaders. | ||
|
||
[Find a PHP Conference][php-conf] | ||
|
||
[php-calendar]: http://www.php.net/cal.php | ||
[google]: https://www.google.com/search?q=php+user+group+near+me | ||
[meetup]: http://www.meetup.com/find/ | ||
[php-wiki]: https://wiki.php.net/usergroups | ||
[php-conf]: http://php.net/conferences/index.php | ||
[phpc-twitter]: https://twitter.com/phpc |
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,26 @@ | ||
(function ($) { | ||
// Load contributors | ||
var $contributors = $('#contributors'); | ||
if ( $contributors.length ) { | ||
var fail = function () { | ||
$contributors.html('<p>This project would not be possible without the help of <a href="https://github.com/codeguy/php-the-right-way/graphs/contributors">our amazing contributors</a> on GitHub.</p>'); | ||
}; | ||
$.ajax({ | ||
cache: false, | ||
dataType: 'jsonp', | ||
timeout: 3000, | ||
type: 'GET', | ||
url: 'https://api.github.com/repos/codeguy/php-the-right-way/contributors' | ||
}).done(function (data) { | ||
if ( data.data && data.data.length ) { | ||
var $ul = $('<ul></ul>'), dataLength = data.data.length; | ||
for ( var i = 0; i < dataLength; i++ ) { | ||
$ul.append(['<li><a href="https://github.com/', data.data[i].login, '" target="_blank">', data.data[i].login, '</a></li>'].join('')); | ||
} | ||
$contributors.html($ul); | ||
} else { | ||
fail(); | ||
} | ||
}).fail(fail); | ||
} | ||
})(jQuery); |