diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..fef422c --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +patreon: darwinbiler +custom: https://www.buymeacoffee.com/kt7vrlS6F diff --git a/.gitignore b/.gitignore index 518747d..3aee9d2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ _site .sass-cache .DS_Store .idea +.jekyll-cache/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6ab212..b867faa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,13 +14,13 @@ patches and features. ## Using the issue tracker -The [issue tracker](https://github.com/laraveltherightway/laraveltherightway.github.io/issues) is +The [issue tracker](https://github.com/laravelbestpractices/laravelbestpractices.github.io/issues) is the preferred channel for changes: spelling mistakes, wording changes, new content and generally [submitting pull requests](#pull-requests), but please respect the following restrictions: * Please **do not** use the issue tracker for personal support requests (use - [Stack Overflow](http://stackoverflow.com/questions/tagged/php) or IRC). + [Stack Overflow](http://stackoverflow.com/questions/tagged/laravelbestpractices) or IRC). * Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others. @@ -95,8 +95,8 @@ owners to license your work under the the terms of the [Creative Commons Attribu The same content and license will be used for all PHP The Right Way publications, including - but not limited to: -* [laraveltherightway.com](http://laraveltherightway.com) -* Translations of laraveltherightway.com +* [laravelbestpractices](https://www.laravelbestpractices.com) +* Translations of www.laravelbestpractices.com All content is completely free now, and always will be. diff --git a/LICENSE b/LICENSE index 8e9a4f2..c337c7f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,3 @@ -Copyright (c) 2013 Josh Lockhart +Copyright (c) 2015 Darwin Biler http://creativecommons.org/licenses/by-nc-sa/3.0/ diff --git a/README.md b/README.md index 6709f0f..3d05058 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Laravel: The Right Way +# Laravel: Best Practices ## Overview -This is the GitHub Pages repository for the _Laravel: The Right Way_ project. +This is the GitHub Pages repository for the _Laravel Best Practices_ project. * This website is a Jekyll project. * Each section and sub-section are a Markdown file in `_posts/`. @@ -11,10 +11,10 @@ This is the GitHub Pages repository for the _Laravel: The Right Way_ project. ## Spread the Word! -_Laravel: The Right Way_ has web banner images you can use on your website. Show your support, and let new PHP +_Laravel: Best Practices_ has web banner images you can use on your website. Show your support, and let new PHP developers know where to find good information! -[See Banner Images](http://www.laraveltherightway.com/banners.html) +[See Banner Images](http://www.laravelbestpractices.com/banners.html) ## How to Contribute @@ -31,13 +31,13 @@ developers know where to find good information! ## Where -<http://www.laraveltherightway.com> +<http://www.laravelbestpractices.com> -* [English](http://www.phptherightway.com) +* [English](http://www.laravelbestpractices.com) ### Translations -If you are interested in translating _Laravel: The Right Way_, fork this repo on GitHub and publish your localized fork to your own GitHub Pages account. We'll link to your translation from the primary document. +If you are interested in translating _Laravel Best Practices_, fork this repo on GitHub and publish your localized fork to your own GitHub Pages account. We'll link to your translation from the primary document. To avoid fragmentation and reader confusion, please choose one of these options: @@ -46,8 +46,6 @@ To avoid fragmentation and reader confusion, please choose one of these options: If you use a subdomain, enter the subdomain into the `CNAME` file, and ask us to setup DNS for you. If you do not use a subdomain, remove the `CNAME` file entirely else your fork will not build when pushed. -Add information about your translation in the [wiki page](https://github.com/laraveltherightway/laraveltherightway.gitjub.io/wiki/Translations). - When your translation is ready, open an issue on the Issue Tracker to let us know. ## Why @@ -56,7 +54,7 @@ There's been a lot of discussion lately about how the PHP community lacks suffic ## Who -My name is [Darwin Biler](http://twitter.com/buonzz). +My name is [Darwin Biler](http://twitter.com/buonzz). I'm an open-source enthusiast and aims to provide a help in developers to use Laravel effectively in their applications. ### Collaborators diff --git a/_config.yml b/_config.yml index 8f818c5..feaedce 100644 --- a/_config.yml +++ b/_config.yml @@ -1,5 +1,5 @@ baseurl: / -highlighter: pygments +highlighter: rouge markdown: kramdown permalink: date maruku: diff --git a/_includes/welcome.md b/_includes/welcome.md index 49e677c..9e23bfc 100644 --- a/_includes/welcome.md +++ b/_includes/welcome.md @@ -1,19 +1,31 @@ # Welcome -_Disclaimer: Majority of the assets, design and format of this site is borrowed (forked might be the more better term) from the original [PHP : The Right Way](http://www.phptherightway.com/) site. The [original contributors](https://github.com/codeguy/php-the-right-way/graphs/contributors) is given all the credits due to them._ +This site serves as a guide for those who is using Laravel Framework by Taylor Otwell and its contributors. <br/> +**Laravel : Best Practices** aims to put together all the resources and best practices in using the Laravel Framework. -This site serves as a guide for those who is using Laravel Framework by Taylor Otwell and its contributors. Laravel : The Right Way aims to put together all the resources and best practices in using the Laravel Framework. - -Laravel Framework is not strict on how and where you define your classes as long as it could be loaded by Composer. This is a double-sided blade -- it's beneficial for advanced developers, but coud be confusing for beginners and for those who is trying to reverse engineer an existing codebase. The ability to place anything, anywhere is good. But there are times some methods is way better than the others, and that is what we are after. This site tried to collect all the best practices, tools and methodologies, so that it could serve a guide for beginners and existing developers alike. +Laravel Framework is not strict on how and where you define your classes as long as it could be loaded by Composer. This is a double-sided blade -- it's beneficial for advanced developers, but could be confusing for beginners and for those who is trying to reverse engineer an existing codebase. The ability to place anything, anywhere is good. But there are times some methods is way better than the others, and that is what we are after. This site tried to collect all the best practices, tools and methodologies, so that it could serve a guide for beginners and existing developers alike. This is a living document and will continue to be updated with more helpful information and examples as they become available. -## Translations -Laravel: The Right Way is currently only available in English language. Please contribute to the project so that it could support multiple languages. +<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> +<ins class="adsbygoogle" + style="display:block" + data-ad-format="fluid" + data-ad-layout-key="-fb+5w+4e-db+86" + data-ad-client="ca-pub-0845730634111642" + data-ad-slot="5495082024"></ins> +<script> + (adsbygoogle = window.adsbygoogle || []).push({}); +</script> + +## Translations -* [English](http://www.laraveltherightway.com) +Laravel: The Best Practices is currently available in the following languages. Please contribute to the project so that it could support multiple languages. +* [English](http://www.laravelbestpractices.com) +* [Russian](http://vanadium23.github.io/laraveltherightway.github.io/) +* [Chinese](http://bluegeek.github.io/laraveltherightway/) ## How to Contribute @@ -21,10 +33,14 @@ Help make this website the best resource for new PHP programmers! [Contribute on ## Spread the Word! -_Laravel: The Right Way_ has web banner images you can use on your website. Show your support, and let new PHP developers +_Laravel Best Practices_ has web banner images you can use on your website. Show your support, and let new PHP developers know where to find good information! [See Banner Images][2] [1]: https://github.com/laraveltherightway/laraveltherightway.github.io [2]: /banners.html + +## Download the Android Application + +[](https://play.google.com/store/apps/details?id=com.buonzz.com.laravelbestpractices) \ No newline at end of file diff --git a/_layouts/default.html b/_layouts/default.html index 04a365a..c197998 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -1,22 +1,55 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="en" prefix="og: http://ogp.me/ns#"> <head> <meta charset="utf-8"/> - <title>{% if page.title %}{{ page.title }} - {% endif %}Laravel: The Right Way</title> + <title>{% if page.title %}{{ page.title }} - {% endif %}Laravel: Best Practices</title> <meta name="description" content="{{ page.description }}"/> <meta name="robots" content="index,follow,archive"/> - <meta property="og:image" content="http://www.laraveltherightway.com/images/og-logo.png"/> - <meta property="og:title" content="Laravel: The Right Way"/> + <link rel="canonical" href="https://www.laravelbestpractices.com" /> + <meta property="og:image" content="http://www.laravelbestpractices.com/images/og-logo.png"/> + <meta property="og:title" content="Laravel: Best Practices"/> <meta property="og:description" content="An easy-to-read, quick reference for Laravel best practices, accepted coding standards, and links to authoritative Laravel tutorials around the Web"/> - <meta property="og:url" content="http://www.laraveltherightway.com"/> - <meta property="og:site_name" content="Laravel: The Right Way"/> + <meta property="og:url" content="http://www.laravelbestpractices.com"/> + <meta property="og:site_name" content="Laravel: Best Practices"/> <meta property="og:type" content="website"/> + <meta property="article:tag" content="coding standards, laravel rules, implementation details, team programming, policies" /> + <meta property="article:section" content="Information Technology" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> <link href='http://fonts.googleapis.com/css?family=Alfa+Slab+One|Droid+Serif:400,700' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="{{ site.baseurl }}styles/all.css"/> <link rel="stylesheet" href="{{ site.baseurl }}styles/print.css" media="print, handheld"/> <link rel="stylesheet" href="{{ site.baseurl }}styles/syntax.css"/> - <link rel="icon" href="{{ site.baseurl }}images/favicon.png" type="image/png"/> + <link rel="icon" href="{{ site.baseurl }}favicon-96x96.png" type="image/png"/> + <meta name="twitter:card" content="summary" /> + <meta name="twitter:description" content="{{ page.description }}" /> + <meta name="twitter:title" content="Laravel Best Practices" /> + <link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png"> + <link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png"> + <link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png"> + <link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png"> + <link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png"> + <link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png"> + <link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png"> + <link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png"> + <link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"> + <link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png"> + <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> + <link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"> + <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> + <link rel="manifest" href="/manifest.json"> + <meta name="msapplication-TileColor" content="#ffffff"> + <meta name="msapplication-TileImage" content="/ms-icon-144x144.png"> + <meta name="theme-color" content="#ffffff"> + <script type="application/ld+json"> + { + "@context": "http://schema.org", + "@type": "WebSite", + "url": "https://www.laravelbestpractices.com", + "name": "Laravel Best Practices", + "description": "{{ page.description }}" + } + </script> + <script data-ad-client="ca-pub-0845730634111642" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> </head> <body> <!-- Google Tag Manager --> @@ -28,6 +61,25 @@ '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-N7WWCH');</script> <!-- End Google Tag Manager --> + + <script> + window.fbAsyncInit = function() { + FB.init({ + appId : '778595608937156', + xfbml : true, + version : 'v2.5' + }); + }; + + (function(d, s, id){ + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) {return;} + js = d.createElement(s); js.id = id; + js.src = "//connect.facebook.net/en_US/sdk.js"; + fjs.parentNode.insertBefore(js, fjs); + }(document, 'script', 'facebook-jssdk')); + </script> + <nav class="site-navigation"> <div class="build-date">Last Updated: {{ site.time }}</div> <ul> @@ -39,11 +91,12 @@ </ul> </li> {% assign lastIsChild = false %} + {% assign insideSection = false %} {% for post in site.posts reversed %} {% if post.isChild != true %} {% if insideSection %} </ul> - </li> + </li><!-- inside section --> {% assign insideSection = false %} {% endif %} {% endif %} @@ -70,12 +123,28 @@ <header class="site-header" id="site-header"> <hgroup> <h1 class="site-title"><a href="/">Laravel</a></h1> - <h2 class="site-slogan">The Right Way.</h2> + <h2 class="site-slogan">Best Practices.</h2> </hgroup> - <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.laraveltherightway.com/" data-size="large" data-hashtags="laraveltherightway">Tweet</a> + + <div + class="fb-like" + data-share="true" + data-width="450" + data-show-faces="false"> + </div> </header> {{ content }} <div id="site-footer"> + <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> + <ins class="adsbygoogle" + style="display:block" + data-ad-format="fluid" + data-ad-layout-key="-fb+5w+4e-db+86" + data-ad-client="ca-pub-0845730634111642" + data-ad-slot="5495082024"></ins> + <script> + (adsbygoogle = window.adsbygoogle || []).push({}); + </script> <h1 id="site-footer_title">Credits</h1> <footer class="site-footer" id="site-footer"> <h2 class="epsilon">Created and maintained by</h2> @@ -90,14 +159,11 @@ <h2 class="epsilon">Project contributors</h2> <div id="contributors">Loading…</div> <h2 class="epsilon">Project sponsors</h2> <ul class="mbd"> - <li> - <a href="http://www.github.com"> - Hosting courtesy of GitHub Pages - </a> - </li> - </ul> + <li><a href="http://www.github.com" rel="nofollow" target="_blank">Hosting courtesy of GitHub Pages</a></li> + <li><a href="https://www.patreon.com/laravelbestpractices">Become a Patron</a></li> + </ul> <p> - <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type">Laravel: The Right Way</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.darwinbiler.com" property="cc:attributionName" rel="cc:attributionURL">Darwin Biler</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="http://www.laraveltherightway.com" rel="dct:source">www.laraveltherightway.com</a>. + <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type">Laravel: Best Practices</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.darwinbiler.com" property="cc:attributionName" rel="cc:attributionURL">Darwin Biler</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="http://www.laravelbestpractices.com" rel="dct:source">www.laravelbestpractices.com</a>. </p> </footer> </div> diff --git a/_layouts/page.html b/_layouts/page.html index 96dbb5d..9eb05e5 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -36,7 +36,6 @@ </a> </header> <div class="interior-site-content"> - <div class="pbh"><em>You are reading extended content about…</em></div> {{ content }} <a href="/">Return to Main Page</a> <footer class="site-footer" id="site-footer"> diff --git a/_posts/01-01-01-Getting-Started.md b/_posts/01-01-01-Getting-Started.md deleted file mode 100644 index 5b28d55..0000000 --- a/_posts/01-01-01-Getting-Started.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -anchor: getting_started ---- - -# Getting Started {#getting_started_title} - diff --git a/_posts/01-01-19-getting-started.md b/_posts/01-01-19-getting-started.md new file mode 100644 index 0000000..155c547 --- /dev/null +++ b/_posts/01-01-19-getting-started.md @@ -0,0 +1,5 @@ +--- +anchor: getting_started +--- + +# Getting Started {#getting_started_title} \ No newline at end of file diff --git a/_posts/01-02-01-Use-the-Current-Stable-Version.md b/_posts/01-02-01-Use-the-Current-Stable-Version.md deleted file mode 100644 index 07305f5..0000000 --- a/_posts/01-02-01-Use-the-Current-Stable-Version.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: Use the Current Stable Version (5.0) -isChild: true -anchor: use_the_current_stable_version ---- - -## Use the Current Stable Version (5.1) {#use_the_current_stable_version_title} - -If you are getting started with Laravel, start with the current stable release of [Laravel 5.0][laravel-release]. Laravel has added -powerful [new features](#framework_highlights) over the last few years. Though the incremental version number difference -between 4.0 and 4.2 is small, it represents _major_ improvements. If you are looking for a function or its usage, the -documentation on the [laravel.com/docs][laravel-docs] website will have the answer. - -[laravel-release]: https://packagist.org/packages/laravel/laravel -[laravel-docs]: http://laravel.com/docs diff --git a/_posts/01-02-19-ecosystem.md b/_posts/01-02-19-ecosystem.md new file mode 100644 index 0000000..689ddf4 --- /dev/null +++ b/_posts/01-02-19-ecosystem.md @@ -0,0 +1,21 @@ +--- +title: The Ecosystem +isChild: true +anchor: the-ecosystem +--- + +## The Ecosystem {#the_ecosystem} + +At the very minimum, you need to know how to use [Git](https://git-scm.com/){:target="_blank"} and [Composer](https://getcomposer.org/){:target="_blank"}. Though not required, it is better that you have an account on [GitHub.com](https://github.com/){:target="_blank"} as it is where all the code and its dependencies are hosted. + +You MUST be comfortable in using [Command Line Interface (CLI)](https://en.wikipedia.org/wiki/Command-line_interface){:target="_blank"}, specially Unix Shells (sh, ksh, csh, tcsh, bash etc) as it is heavily used for common tasks in working with Laravel. + +For local development, you’ll need to have at least [Vagrant](https://www.vagrantup.com/){:target="_blank"} and [VirtualBox](https://www.virtualbox.org/){:target="_blank"} installed. This is used by [Homestead](https://laravel.com/docs/5.8/homestead){:target="_blank"} (a special vagrant box made for running Laravel apps). Although you can use the traditional WAMP/MAMP/XAMPP stack, those are not officially supported, thus you might have hard time down the road. + +Pure “Laravel-way” frontend development might be a daunting one as it got has a long chain of technologies. You can either use [Laravel Blade](https://laravel.com/docs/7.x/blade){:target="_blank"} which is server-side templating or do client-side (browser), which at the very top of the chain is [Mix](https://laravel.com/docs/7.x/mix){:target="_blank"}, a wrapper for [Webpack](https://webpack.js.org/){:target="_blank"}. Webpack has its dependencies managed through [npm](https://www.npmjs.com/), all of which are packages of [NodeJS](https://nodejs.org/en/){:target="_blank"}. + +CSS is managed either through [Sass](http://sass-lang.com/){:target="_blank"} or [LESS](http://lesscss.org/){:target="_blank"}, while JavaScript can be done through Plain JavaScript, [ReactJS](https://reactjs.org/){:target="_blank"} and the more common frontend framework used with Laravel: [VueJS](https://vuejs.org/){:target="_blank"}. + +For the backend stack, at the very least, you need a web server like [Nginx](http://nginx.org/){:target="_blank"}, a php interpreter like [PHP-FPM](http://php-fpm.org/){:target="_blank"} and a database like [MySQL](https://www.mysql.com/){:target="_blank"}. Other optional stack components are [Memcached](http://memcached.org/){:target="_blank"}, [Redis](http://redis.io/){:target="_blank"} and [Beanstalkd](http://kr.github.io/beanstalkd/){:target="_blank"}. + +While you are not required to understand them all at once, it is advantagous that you are at least familiar with these and do some reading about what they are and where they are being used. This will save you tons of confusion when reading the documentation and references in the future. diff --git a/_posts/01-03-01-Built-in-Web-Server.md b/_posts/01-03-01-Built-in-Web-Server.md deleted file mode 100644 index 04891f1..0000000 --- a/_posts/01-03-01-Built-in-Web-Server.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: Built-in Web Server -isChild: true -anchor: builtin_web_server ---- - -## Built-in web server {#builtin_web_server_title} - -You might notice a server.php in the Laravel codes. The purpose of this is for you to be able to run the project without even having a web server installed (e.g Apache or Nginx). This is primarily for development purpose only. This leverages the PHP 5.4's internal web server. You can use that by issuing either of the following commands: - -{% highlight console %} -> php -S localhost:8000 server.php -{% endhighlight %} - -or simply (note that the following **only** works for Laravel `v4.x`): - -{% highlight console %} -> php artisan serve -{% endhighlight %} - -You can also specify optional parameters - -{% highlight console %} -> php artisan serve --port=8080 --host=local.dev -{% endhighlight %} diff --git a/_posts/01-03-19-how-to-read-this-guide.md b/_posts/01-03-19-how-to-read-this-guide.md new file mode 100644 index 0000000..b5db62e --- /dev/null +++ b/_posts/01-03-19-how-to-read-this-guide.md @@ -0,0 +1,27 @@ +--- +title: How to read this guide +isChild: true +anchor: how-to-read-this-guide +--- + +## How to read this guide {#how-to-read-this-guide} + +This guide is divided into several sections such as each one tries to group related conventions. For example, all database-related convention is grouped in the same section. Each of the convention have the following keywords, which indicates how important it is to comply with such convention: + +* **MUST** This word, or the terms "REQUIRED" or "SHALL", mean that the + definition is an absolute requirement of the specification. +* **MUST NOT** This phrase, or the phrase "SHALL NOT", mean that the + definition is an absolute prohibition of the specification. +* **SHOULD** This word, or the adjective "RECOMMENDED", mean that there + may exist valid reasons in particular circumstances to ignore a + particular item, but the full implications must be understood and + carefully weighed before choosing a different course. +* **SHOULD NOT** This phrase, or the phrase "NOT RECOMMENDED" mean that + there may exist valid reasons in particular circumstances when the + particular behavior is acceptable or even useful, but the full + implications should be understood and the case carefully weighed + before implementing any behavior described with this label. +* **MAY** This word, or the adjective "OPTIONAL", mean that an item is + truly optional. + +the above specifications is derived from [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt){:target="_blank"} \ No newline at end of file diff --git a/_posts/01-04-01-Homestead.md b/_posts/01-04-01-Homestead.md deleted file mode 100644 index 8a43230..0000000 --- a/_posts/01-04-01-Homestead.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -isChild: true -anchor: homestead ---- - -## Homestead {#homestead_title} - -Laravel is not only using Vagrant as the official development environment but also has its own base box called "Homestead". -You can use Homestead to start developing with Laravel without the hassle of setting up your local environment for Laravel. - -The instructions and usage of homestead can be found in the [Official Documentation][homestead-docs]. - -[homestead-docs]: http://laravel.com/docs/5.0/homestead diff --git a/_posts/01-05-01-32bit-homestead.md b/_posts/01-05-01-32bit-homestead.md deleted file mode 100644 index 786f12a..0000000 --- a/_posts/01-05-01-32bit-homestead.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -isChild: true -anchor: 32bit-homestead ---- - -## Homestead for 32-bit Machines {#homestead32bit_title} - -There are instances though that Homestead wont run in your 32-bit development computer because you can't enable hardware virtualization (VT-x). This is required by Homestead because the basebox being used to build the Homestead is using ubuntu/trusty64 box, which is a 64-bit machine. For some people who can't enable it in their BIOS, or their computer has no support for VT-x at all, you can use the 32-bit version of the Homestead in [here][32bit-homestead-here] - -[32bit-homestead-here]: https://github.com/buonzz/homestead32 \ No newline at end of file diff --git a/_posts/01-05-02-Custom-Homestead.md b/_posts/01-05-02-Custom-Homestead.md deleted file mode 100644 index e25296c..0000000 --- a/_posts/01-05-02-Custom-Homestead.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -isChild: true -anchor: custom_homestead ---- - -## Build your own Homestead {#custom_homestead_title} - -When you use Homestead, there are pre-defined softwares already installed. If you want to customize the installed softwares, you will need to have an access to the scripts that is used to build Homestead itself. This project is called ["Settler"][settler-url]. You can check the source codes of that project to have a better understanding on how the Homestead was built, and probably add your own scripts as well. - -[settler-url]: https://github.com/laravel/settler \ No newline at end of file diff --git a/_posts/02-01-01-Code-Style-Guide.md b/_posts/02-01-01-Code-Style-Guide.md deleted file mode 100644 index 561fa02..0000000 --- a/_posts/02-01-01-Code-Style-Guide.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -anchor: code_style_guide ---- - -# Code Style Guide {#code_style_guide_title} - -The Laravel framework itself doesn't impose standards on how you should name your variables or where to put files. As long as it can be loaded by Composer, it will technically run inside the application. However, developers are encouraged to study and follow the following PSR standards: - -* [PSR-0] [psr0] -* [PSR-1] [psr1] -* [PSR-2] [psr2] -* [PSR-4] [psr4] - -[fig]: http://www.php-fig.org/ -[psr0]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md -[psr1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md -[psr2]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md -[psr4]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md -[pear-cs]: http://pear.php.net/manual/en/standards.php -[zend-cs]: http://framework.zend.com/wiki/display/ZFDEV2/Coding+Standards -[symfony-cs]: http://symfony.com/doc/current/contributing/code/standards.html -[phpcs]: http://pear.php.net/package/PHP_CodeSniffer/ -[st-cs]: https://github.com/benmatselby/sublime-phpcs -[phpcsfixer]: http://cs.sensiolabs.org/ -[phptools]: https://github.com/dericofilho/php.tools -[sublime-phpfmt]: https://github.com/dericofilho/sublime-phpfmt diff --git a/_posts/02-01-19-environment.md b/_posts/02-01-19-environment.md new file mode 100644 index 0000000..63df8c4 --- /dev/null +++ b/_posts/02-01-19-environment.md @@ -0,0 +1,5 @@ +--- +anchor: environment +--- + +# Environment {#environment_title} \ No newline at end of file diff --git a/_posts/02-02-19-local.md b/_posts/02-02-19-local.md new file mode 100644 index 0000000..286aa01 --- /dev/null +++ b/_posts/02-02-19-local.md @@ -0,0 +1,28 @@ +--- +title: Local Environment +isChild: true +anchor: local-environment +--- + +## Local Environment {#local-environment} + +There are multiple ways to run Laravel in local environment as outlined below: + +* [**Homestead**](https://laravel.com/docs/5.8/homestead){:target="_blank"} - requires VirtualBox, Vagrant +* [**Valet**](https://laravel.com/docs/5.8/valet){:target="_blank"} - only runs in MacOS +* [**Laradock**](https://laradock.io/){:target="_blank"} - requires Docker Engine + +You are free to choose which local environment that works for you and your team as long as the following conditions are met: + +- Your local environment **MUST** be able to duplicate the production server or close to its specifications such as PHP version, extensions installed and MySQL version + +- .env file **MUST NOT** be commited into repository + +- You **SHOULD NOT** be connecting to your any production server when you are debugging locally, to prevent accidental corruption of data, unintended API call or similar incident. + +- You **SHOULD NOT** be using personally identiable information (PII) of your end-users data or any data that could potentially identify a specific individual such as first/last name, address, medical condition so on and so forth, unless you are explicitly authorized by your company or client to do so. + +- You **MUST** update the readme.md file for any special instruction on how to run the app in local environment, so that other developers who will setup the app in their local machine can follow them properly. + +- While it is possible to WAMP or XAMP for Laravel, this is un-common practice +so you **SHOULD** try to familiarize yourself on how server components works and be comfortable in dealing with them. \ No newline at end of file diff --git a/_posts/02-03-19-staging.md b/_posts/02-03-19-staging.md new file mode 100644 index 0000000..5d050f9 --- /dev/null +++ b/_posts/02-03-19-staging.md @@ -0,0 +1,12 @@ +--- +title: Staging Environment +isChild: true +anchor: staging-environment +--- + +## Staging Environment {#staging-environment} + +Staging servers is a type of server that is used to test a software, website or service in a production-similar environment before being set live. It is the role of a staging environment or staging site, to serve as a temporary hosting and testing server for any new software or feature. + +- It is **RECOMMENDED** to use [**Continous Integration**](https://www.thoughtworks.com/continuous-integration){:target="_blank"} to automatically run your Tests and keep a record of the results. For example [Travis CI](https://travis-ci.org/){:target="_blank"} or [Jenkins](https://jenkins.io/){:target="_blank"} + diff --git a/_posts/02-04-19-production.md b/_posts/02-04-19-production.md new file mode 100644 index 0000000..7afc637 --- /dev/null +++ b/_posts/02-04-19-production.md @@ -0,0 +1,20 @@ +--- +title: Production Environment +isChild: true +anchor: production-environment +--- + +## Production Environment {#production-environment} + + +### You MUST regularly rotate your APP_KEY + +APP_KEYS are set when you initialized a new Laravel application or executed the following command + +``` +php artisan key:generate +``` + +> Laravel uses the key for all encrypted cookies, including the session cookie, before handing them off to the user's browser, and it uses it to decrypt cookies read from the browser. This prevents the client from making changes to their cookies and granting themselves admin privileges or impersonating another user in your application. Encrypted cookies are an important security feature in Laravel + +From [APP_KEY And You](https://tighten.co/blog/app-key-and-you){:target="_blank"} \ No newline at end of file diff --git a/_posts/03-01-01-Framework-Highlights.md b/_posts/03-01-01-Framework-Highlights.md deleted file mode 100644 index e40734a..0000000 --- a/_posts/03-01-01-Framework-Highlights.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -anchor: framework_highlights ---- - -# Framework Highlights {#framework_highlights_title} diff --git a/_posts/03-01-19-configuration.md b/_posts/03-01-19-configuration.md new file mode 100644 index 0000000..c4c425a --- /dev/null +++ b/_posts/03-01-19-configuration.md @@ -0,0 +1,5 @@ +--- +anchor: configuration +--- + +# Configuration {#configuration_title} \ No newline at end of file diff --git a/_posts/03-02-01-Programming-Paradigms.md b/_posts/03-02-01-Programming-Paradigms.md deleted file mode 100644 index b7d476a..0000000 --- a/_posts/03-02-01-Programming-Paradigms.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -isChild: true -anchor: programming_paradigms ---- - -## Programming Paradigms {#programming_paradigms_title} - - -Design Patterns - -There are several design patterns that powers Laravel. Phill Sparks has wonderful presentation about this. - -<iframe src="//www.slideshare.net/slideshow/embed_code/25783148" width="427" height="356" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen=""> </iframe> \ No newline at end of file diff --git a/_posts/03-02-19-environment-variables.md b/_posts/03-02-19-environment-variables.md new file mode 100644 index 0000000..5b6811b --- /dev/null +++ b/_posts/03-02-19-environment-variables.md @@ -0,0 +1,56 @@ +--- +title: Environment Variables +isChild: true +anchor: environment-variables +--- + +## Environment Variables {#environment-variables} + + +### You MUST put sensitive information into .env files +Use .env files to store any secure information and retrieve it via __env__ function. There should be no instance on which you will put it inside models/controllers and commit it to Git. + +Good +``` +// .env + +API_HOST=https://example.com/api +API_USERNAME=myuser +API_PASSWORD=secret + + +// access the value from app/config.php file + +return [ + ... + 'api_host' => env('API_HOST', 'https://defaultdomain.com') + 'api_username' => env('API_USER', 'defaultuser') + 'api_password' => env('API_USER', 'defaultpassword') + ... +] + +``` + + +Bad +``` +define('API_HOST', 'https://defaultdomain.com'); +define('API_USERNAME', 'defaultuser'); +define('API_PASSWORD', 'defaultpassword'); + +class DomainController extends Controller +{ + public function index() + { + $api_username + } + +``` + + + +### your application key MUST be set. This is the APP_KEY variable in your .env file. You can generate one via + +``` +php artisan key:generate +``` diff --git a/_posts/03-03-01-how-it-works.md b/_posts/03-03-01-how-it-works.md deleted file mode 100644 index 96715c8..0000000 --- a/_posts/03-03-01-how-it-works.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -isChild: true -anchor: howitworks ---- - -## How Laravel Works? {#howitworks_title} - -Christopher Pitt has impressive explanation of the inner workings of Laravel, you can check it out in [http://rebuildinglaravel.com/] [rebuild-laravel-url] - -[rebuild-laravel-url]: http://rebuildinglaravel.com/ \ No newline at end of file diff --git a/_posts/03-04-01-eloquent-orm.md b/_posts/03-04-01-eloquent-orm.md deleted file mode 100644 index c22e343..0000000 --- a/_posts/03-04-01-eloquent-orm.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Eloquent ORM -isChild: true -anchor: eloquent_orm ---- - -## Eloquent ORM {#eloquent_orm_title} - -The most popular feature of Laravel is it's rockstar ORM called Eloquent. It's the easiest way to use an ORM in your application. You can read more about Eloquent in the [official documentation][eloquent-url]. - -[eloquent-url]:http://laravel.com/docs/5.0/eloquent \ No newline at end of file diff --git a/_posts/03-04-19-package-configuration.md b/_posts/03-04-19-package-configuration.md new file mode 100644 index 0000000..e3d893c --- /dev/null +++ b/_posts/03-04-19-package-configuration.md @@ -0,0 +1,43 @@ +--- +title: Package Configuration +isChild: true +anchor: package-configuration +--- + +## Package Configuration {#package-configuration} + +### Custom or Package configuration filename MUST be in snake_case + +Good +``` +config/my_config.php +``` + +Bad +``` +config/MyConfig.php +``` + +### Config and language files indexes SHOULD be in snake_case + +Good +``` +// config/myconfig.php +return [ + 'my_api' => [ + 'domain' => env('API_DOMAIN'), + 'secret' => env('API_SECRET'), + ], +``` + +Bad +``` +// config/myconfig.php +return [ + 'MyApi' => [ + 'DOMAIN' => env('API_DOMAIN'), + 'SECRET' => env('API_SECRET'), + ], +``` + +> The best way to figure out if you have implemented best-practice in configuring your app, is if the codebase could be made open source at any moment without compromising any credentials diff --git a/_posts/03-05-01-Command-Line-Interface.md b/_posts/03-05-01-Command-Line-Interface.md deleted file mode 100644 index 43148ec..0000000 --- a/_posts/03-05-01-Command-Line-Interface.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -isChild: true -anchor: command_line_interface ---- - -## Command Line Interface {#command_line_interface_title} - -Laravel comes with its own command line interface called [Artisan][artisan-url]. It is basically using the [Symfony Console][symfony-url] component as its foundation. Laracasts has good [tutorials][laracasts-url] on understanding how commands works and how to make your own. - -[artisan-url]:http://laravel.com/docs/5.0/artisan -[symfony-url]:https://github.com/symfony/Console -[laracasts-url]:https://laracasts.com/lessons/commands-101 \ No newline at end of file diff --git a/_posts/03-06-01-Debugging.md b/_posts/03-06-01-Debugging.md deleted file mode 100644 index c31e9b7..0000000 --- a/_posts/03-06-01-Debugging.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Debuging -isChild: true -anchor: debugging ---- - -## Debugging {#debugging_title} - -Laravel's cool error page is something that it is known for. Thanks for the [Whoops library][whoops-url] which powers the error page you are seeing whenever there is an error. - -[whoops-url]:https://github.com/filp/whoops \ No newline at end of file diff --git a/_posts/04-01-01-Dependency-Management.md b/_posts/04-01-01-Dependency-Management.md deleted file mode 100644 index b2fcbf8..0000000 --- a/_posts/04-01-01-Dependency-Management.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -anchor: dependency_management ---- - -# Dependency Management {#dependency_management_title} - -Laravel is not built from scratch. It is built on top of several framework and libraries. You can see the listing of other libraries it is using [here][dependencies-laravel]. It is also being powered by [Illuminate components][illuminate]. All of these components are being tied into each other by making sure each of them can be treated and written as a composer [Composer library][comp-lib]. These libraries is hosted in public repositories. - -[dependencies-laravel]:https://github.com/laravel/framework/blob/5.0/composer.json#L22-L43 -[illuminate]:https://github.com/illuminate -[comp-lib]:https://getcomposer.org/doc/02-libraries.md \ No newline at end of file diff --git a/_posts/04-01-19-naming-conventions.md b/_posts/04-01-19-naming-conventions.md new file mode 100644 index 0000000..0c71e25 --- /dev/null +++ b/_posts/04-01-19-naming-conventions.md @@ -0,0 +1,9 @@ +--- +anchor: naming_conventions +title: Naming Conventions +--- + +# Naming Conventions {#naming_conventions_title} + +The following is the generally accepted naming conventions being used by Laravel Community: + diff --git a/_posts/04-02-01-Composer-and-Packagist.md b/_posts/04-02-01-Composer-and-Packagist.md deleted file mode 100644 index bbd232d..0000000 --- a/_posts/04-02-01-Composer-and-Packagist.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -isChild: true -anchor: composer_and_packagist ---- - -## Composer and Packagist {#composer_and_packagist_title} - -By default, it is using Packagist as repository and GitHub to download the files itself. But you can define your own repositories by setting up your own [Satis][satis] mirror of packages. Although you can use any class or even plain php functions inside Laravel (as long as it can be autoloaded). This is not a recommended practice. Make your own [Composer library][own-composer] for each application specific classes and include it as a dependency in the composer.json file. - -[satis]:https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md -[own-composer]:http://knpuniversity.com/screencast/question-answer-day/create-composer-package \ No newline at end of file diff --git a/_posts/04-02-19-controllers.md b/_posts/04-02-19-controllers.md new file mode 100644 index 0000000..7158065 --- /dev/null +++ b/_posts/04-02-19-controllers.md @@ -0,0 +1,63 @@ +--- +title: Controllers +isChild: true +anchor: controllers +--- + +## Controllers {#controllers} + +### Controller name MUST start with a noun (in singular form) followed by the word "Controller". + +**Good** + +``` +class ArticleController extends Controller +{ +``` + +**Bad** + +``` +class ArticlesController extends Controller +{ +``` + +``` +class wp_articlesController extends Controller +{ +``` + +``` +class Article extends Controller +{ +``` + +## You SHOULD Use Resource Controllers unless you have any particular reason not to do so + +Good +``` +class DomainController extends Controller +{ + public function index(){} // list domains + public function create(){} // show create form + public function store(Request $request){ } // handle the form POST + public function show($id){} // show a single domain + public function edit($id){} // show edit page + public function update(Request $request, $id){} // handle show edit page POST + public function destroy($id){} // delete a domain +} +``` + + +Bad + +``` +class DomainController extends Controller +{ + public function list(){} // list domains + public function create_or_save(){} // show create form then handle save + public function show_edit($id){} // show a single domain then show edit page + public function delete($id){} // delete a domain +} +``` + diff --git a/_posts/04-03-01-Laravel-Package-Archivists.md b/_posts/04-03-01-Laravel-Package-Archivists.md deleted file mode 100644 index 5d5327b..0000000 --- a/_posts/04-03-01-Laravel-Package-Archivists.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -isChild: true -anchor: laravel_package_archivists ---- - -## Laravel Package Archivists {#laravel_package_archivists_title} - -Following are the sites where you can find Laravel Packages: - -* [Packalyst](http://packalyst.com) - Find and place package requests. -* [Packagist Laravel](https://packagist.org/search/?tags=laravel) - Find Laravel packages in Packagist. diff --git a/_posts/04-03-19-models.md b/_posts/04-03-19-models.md new file mode 100644 index 0000000..b2e88f8 --- /dev/null +++ b/_posts/04-03-19-models.md @@ -0,0 +1,115 @@ +--- +title: Models +isChild: true +anchor: models +--- + +## Models {#models} + +### Model names MUST be in singular form with its first letter in uppercase + +Good + +``` +class Flight extends Model +{ +... +``` + +Bad + +``` +class Flights extends Model +{ +... +``` + +``` +class flight extends Model +{ +... +``` + +### hasOne or belongsTo relationship methods MUST be in singular form + + +Good +``` +class User extends Model +{ + public function phone() + { + return $this->hasOne('App\Phone'); + } +} +``` + +Bad +``` +class User extends Model +{ + public function phones() + { + return $this->hasOne('App\Phone'); + } +} +``` + +### Any other relationships other than above MUST be in plural form + +Good +``` +class Post extends Model +{ + public function comments() + { + return $this->hasMany('App\Comment'); + } +} +``` + +Bad +``` +class Post extends Model +{ + public function comment() + { + return $this->hasMany('App\Comment'); + } +} +``` + +### Model properties should be in snake_case + +Good +``` +$user->created_at +``` + +Bad +``` +$user->createdAt +``` + +#### Methods should be in camelCase + +Good +``` +class User extends Model +{ + public function scopePopular($query) + { + return $query->where('votes', '>', 100); + } +``` + +Bad + +``` +class User extends Model +{ + public function scope_popular($query) + { + return $query->where('votes', '>', 100); + } +``` \ No newline at end of file diff --git a/_posts/04-04-19-functions.md b/_posts/04-04-19-functions.md new file mode 100644 index 0000000..f0587f5 --- /dev/null +++ b/_posts/04-04-19-functions.md @@ -0,0 +1,72 @@ +--- +title: Functions +isChild: true +anchor: functions +--- + +## Functions {#functions} + +Laravel comes with a lot of useful helper functions, but you can also define your own helper functions, given the following conditions: + +### You SHOULD place your custom helper functions by creating a file called helper.php + +Good +``` +project_folder/app/helper.php +project_folder/app/Http/helper.php +``` + +Bad +``` +project_folder/functions.php +``` + +### You MUST use Composer's autoloading capability to load your functions + +Good +``` +// file composer.json +... +"autoload": { + "files": [ + "app/helpers.php" + ], +... +``` + +Bad +``` +// file app/Http/Controllers/HomeController.php + +class HomeController.php +{ + function index(){ + require_once(app_path("helpers.php")); + } +} + +``` + +### You MUST check if the the function exists before defining it + +Good +``` +if (! function_exists('my_custom_helper')) { + function my_custom_helper($key, $default = null) { + // ... + } +} +``` + +Bad +``` +function my_custom_helper($key, $default = null) { + // ... +} +``` +### Other General guides with functions + +- If the function length exceeds 25 lines, you SHOULD break it down to multiple functions +- Each function SHOULD have a __Unit Test__ associated with it + + diff --git a/_posts/04-05-19-routes.md b/_posts/04-05-19-routes.md new file mode 100644 index 0000000..47a457a --- /dev/null +++ b/_posts/04-05-19-routes.md @@ -0,0 +1,55 @@ +--- +title: Routes +isChild: true +anchor: routes +--- + +## Routes {#routes} + + +### Routes should be in plural form of the resource it is trying to manipulate and SHOULD be all lower-case + +Good + +``` +Route::get('/users', 'UserController@index'); +``` + +``` +Route::resource('photos', 'PhotoController'); +``` + +Bad + +``` +Route::get('/user', 'UserController@index'); +``` + +``` +Route::get('/UsersList', 'UserController@index'); +``` + + +``` +Route::resource('PHOTO', 'PhotoController'); +``` + + +### Named Routes SHOULD use snake_case and dot notation + +Good + +``` +Route::get('/user', 'UserController@active')->name('users.show_active'); +``` + +Bad + +``` +Route::get('/user', 'UserController@active')->name('users.show-active'); +``` + +``` +Route::get('/user', 'UserController@active')->name('show-active-users'); +``` + diff --git a/_posts/04-06-19-variables.md b/_posts/04-06-19-variables.md new file mode 100644 index 0000000..3c20b02 --- /dev/null +++ b/_posts/04-06-19-variables.md @@ -0,0 +1,45 @@ +--- +title: Variables +isChild: true +anchor: variables +--- + +## Variables {#variables} + +### General rule for variable is it SHOULD be in camelCase + +Good +``` +$articlesWithAuthor +``` + +Bad +``` +$articles_with_author +``` + +### Collection names SHOULD be descriptive and in plural form + +Good +``` +$activeUsers = User::active()->get() +``` + +Bad +``` +$users = User::active()->get() +$user = User::active()->get() +$User = User::active()->get() +``` + +### Single Object SHOULD be descriptive and in singular form + +Good +``` +$activeUser = User::active()->first() +``` + +Bad +``` +$users = User::active()->first() +``` \ No newline at end of file diff --git a/_posts/04-07-19-views.md b/_posts/04-07-19-views.md new file mode 100644 index 0000000..8cba03d --- /dev/null +++ b/_posts/04-07-19-views.md @@ -0,0 +1,48 @@ +--- +title: Views +isChild: true +anchor: views +--- + +## Views {#views} + +### You SHOULD use snake_case as file name of your Blade templates + +Good +``` +show_filtered.blade.php +``` + +Bad +``` +showFiltered.blade.php +show-filtered.blade.php +``` + + +### You MUST not make non UI-related operations inside blade templates + +Good +<pre> +{% raw %} +// $api_results is passed by controller +<ul> + @foreach($api_results as $result) + <li>{{ $result->name }}</li> + @endforeach +</ul> +{% endraw %} +</pre> +Bad +<pre> +{% raw %} +@php + $api_results = json_decode(file_get_contents("https://api.example.com")); +@endphp +<ul> + @foreach($api_results as $result) + <li>{{ $result->name }}</li> + @endforeach +</ul> +{% endraw %} +</pre> \ No newline at end of file diff --git a/_posts/05-01-01-Coding-Practices.md b/_posts/05-01-01-Coding-Practices.md deleted file mode 100644 index 8c41fd7..0000000 --- a/_posts/05-01-01-Coding-Practices.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -anchor: coding_practices ---- - -# Coding Practices {#coding_practices_title} diff --git a/_posts/05-01-19-database-conventions.md b/_posts/05-01-19-database-conventions.md new file mode 100644 index 0000000..ab38b27 --- /dev/null +++ b/_posts/05-01-19-database-conventions.md @@ -0,0 +1,6 @@ +--- +anchor: database_conventions +--- + +# Database Conventions {#database_conventions_title} + diff --git a/_posts/05-02-01-The-Basics.md b/_posts/05-02-01-The-Basics.md deleted file mode 100644 index b3d5717..0000000 --- a/_posts/05-02-01-The-Basics.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -isChild: true -anchor: the_basics ---- - -## The Basics {#the_basics_title} - -Laravel has tons of features which might be overwhelming at first. - -Here are some articles and resources that may be useful to get on the same page with Laravel. - -* [Composer: Part 1 – What & Why?][li1] -* [Why use an autoloader? why just don't require the files?][li2] -* [Why CodeIgniter over Laravel - 5 Things CodeIgniter cannot do without a rewrite?][li3] -* [How to install Laravel in WAMP?][li4] -* [Object-Oriented Bootcamp on Laracasts][li5] -* [Laravel 5 from Scratch on Laracasts][li6] - -[li1]:http://nelm.io/blog/2011/12/composer-part-1-what-why/ -[li2]:http://www.sitepoint.com/autoloading-and-the-psr-0-standard/ -[li3]:https://philsturgeon.uk/blog/2012/12/5-things-codeigniter-cannot-do-without-a-rewrite -[li4]:http://www.darwinbiler.com/how-to-install-laravel-on-wamp-for-beginners/ -[li5]:https://laracasts.com/series/object-oriented-bootcamp-in-php -[li6]:https://laracasts.com/series/laravel-5-from-scratch/ diff --git a/_posts/05-02-19-table-fields-naming.md b/_posts/05-02-19-table-fields-naming.md new file mode 100644 index 0000000..784786d --- /dev/null +++ b/_posts/05-02-19-table-fields-naming.md @@ -0,0 +1,102 @@ +--- +title: Table and Fields Naming +isChild: true +anchor: table-fields-naming +--- + +## Table and Fields Naming {#table-fields-naming} + +### Table names MUST be in plural form and MUST be all lower-case + +Good + +``` +class CreateFlightsTable extends Migration +{ + public function up() + { + Schema::create('flights', function (Blueprint $table) { +``` + +Bad + +``` +class CreateFlightsTable extends Migration +{ + public function up() + { + Schema::create('flight', function (Blueprint $table) { +``` + + +``` +class CreateUsersTable extends Migration +{ + public function up() + { + Schema::create('MyUsers', function (Blueprint $table) { +``` + +### Pivot table names MUST be in singular model names in alphabetical order + +Good + +``` +post_user +article_user +photo_post +``` + +Bad +``` +posts_users +user_articles +post_photos +``` + +### Table column names SHOULD be in snake_case without the model name + +Good + +``` +username +title +thumb_url +``` + +Bad +``` +UserName +_title +ThumbUrl +post_title +``` + +### Foreign keys MUST be singular model name with _id suffix + +Good +``` +user_id +``` + +Bad +``` +userid +siteid +Memberid +TransactionID +``` + +### Primary Keys SHOULD be "id" + +Good +``` +id +``` + +Bad +``` +ID +pkid +guid +``` diff --git a/_posts/05-03-01-Date-and-Time.md b/_posts/05-03-01-Date-and-Time.md deleted file mode 100644 index cb45fa9..0000000 --- a/_posts/05-03-01-Date-and-Time.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -isChild: true -anchor: date_and_time ---- - -## Date and Time {#date_and_time_title} - -Although PHP has a class named DateTime to help you when reading, writing, comparing or calculating with date and time. It is recommended that you use the [Carbon library][carbon-url] for dealing with dates. - -[carbon-url]:https://github.com/briannesbitt/Carbon \ No newline at end of file diff --git a/_posts/05-03-19-database-alterations.md b/_posts/05-03-19-database-alterations.md new file mode 100644 index 0000000..3de6e2f --- /dev/null +++ b/_posts/05-03-19-database-alterations.md @@ -0,0 +1,39 @@ +--- +title: Database Alterations +isChild: true +anchor: database-alterations +--- + +## Database Alterations {#database-alterations} + + +### You MUST not be changing the database schema directly, use Database Migrations instead + +Good +``` +php artisan migrate +``` + +Bad + +- use of PHPMyAdmin +- directly executing ALTER statement in mysql console / cli +- using sql file to change the db + + +### Migration filenames MUST follow to following pattern + +creation of table +``` +yyyy_mm_dd_<timestamp>_create_<table name>_table +``` +Good + +``` +2019_06_06_164210_create_domains_table.php +``` + +Bad +``` +2019_06_06_164210_domains.php +``` \ No newline at end of file diff --git a/_posts/05-04-01-Design-Patterns.md b/_posts/05-04-01-Design-Patterns.md deleted file mode 100644 index e37f315..0000000 --- a/_posts/05-04-01-Design-Patterns.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -isChild: true -anchor: design_patterns ---- - -## Design Patterns {#design_patterns_title} - -It is easy to get the your Laravel application to get messed up if you don't have any sort of pattern to follow. The following design patterns are recommended for those who are building an application with Laravel or want to refactor their existing projects: - -* [Domain Driven Design][ddd-url] -* [Don't call Eloquent models directly, Use Repositories!][repo-url] -* [Inversion Of Control Container and Dependency Injection][ioc-url] -* [SOLID Principle][solid-url] - -[ddd-url]:http://caughtexceptions.blogspot.co.nz/2014/02/domain-driven-design-in-laravel-4-part-1.html -[repo-url]:http://vegibit.com/laravel-repository-pattern/ -[ioc-url]:http://www.sitepoint.com/dependency-injection-laravels-ioc/ -[solid-url]:http://en.wikipedia.org/wiki/SOLID_(object-oriented_design) \ No newline at end of file diff --git a/_posts/05-04-19-database-choice.md b/_posts/05-04-19-database-choice.md new file mode 100644 index 0000000..be9b49a --- /dev/null +++ b/_posts/05-04-19-database-choice.md @@ -0,0 +1,22 @@ +--- +title: Database Choice +isChild: true +anchor: database-choice +--- + +## Database Choice {#database-choice} + +### Polyglot Persistence + +Is a practice of using different data storage technologies for different kinds of data. Eloquent ORM can support multiple database for a reason, so don't limit yourself to MySQL. + +- It is RECOMMENDED to use [MongoDB](https://github.com/jenssegers/Laravel-MongoDB){:target="_blank"} for records that have attributes that vary a lot. For example, in an inventory system, an office supplies product might have a different set of fields compared to vehicle and auto supplies. + +- It is RECOMMENDED to use [ElasticSearch](https://github.com/elasticquent/Elasticquent){:target="_blank"} for high volume data searching and indexing. + +- It is RECOMMENDED to use [Neo4J](https://github.com/Vinelab/NeoEloquent){:target="_blank"} for applications that require complex relationships between models. For example a multi-level networking application, social network site and similar apps. + +From this [article](https://martinfowler.com/bliki/PolyglotPersistence.html){:target="_blank"}, here is a sample breakdown of different databases being used by a retailer company + + + diff --git a/_posts/05-05-01-PHP-and-UTF8.md b/_posts/05-05-01-PHP-and-UTF8.md deleted file mode 100644 index a0eb475..0000000 --- a/_posts/05-05-01-PHP-and-UTF8.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: Working with UTF-8 -isChild: true -anchor: php_and_utf8 ---- - -## Working with UTF-8 {#php_and_utf8_title} - -Laravel uses the [patchwork/utf8][patchwork] for most of it's UT8-related stuffs. It is required that all developers understands the following concepts: - -* [Character Sets / Character Encoding Issues][li-1] -* [Handling UTF-8 with PHP][li-2] -* [Unicode Normalization][li-3] -* [Grapheme Clusters][li-4] -* [Unicode Security Considerations][li-5] - - -[patchwork]:https://github.com/nicolas-grekas/Patchwork-UTF8 -[li-1]:http://www.phpwact.org/php/i18n/charsets -[li-2]:http://www.phpwact.org/php/i18n/utf-8 -[li-3]:http://en.wikipedia.org/wiki/Unicode_equivalence -[li-4]:http://unicode.org/reports/tr29/ -[li-5]:http://www.unicode.org/reports/tr36/#Deletion_of_Noncharacters \ No newline at end of file diff --git a/_posts/06-01-19-design-patterns.md b/_posts/06-01-19-design-patterns.md new file mode 100644 index 0000000..635de6e --- /dev/null +++ b/_posts/06-01-19-design-patterns.md @@ -0,0 +1,5 @@ +--- +anchor: Design Patterns +--- + +# Design Patterns {#design_patterns_title} \ No newline at end of file diff --git a/_posts/06-02-19-solid.md b/_posts/06-02-19-solid.md new file mode 100644 index 0000000..150a31c --- /dev/null +++ b/_posts/06-02-19-solid.md @@ -0,0 +1,24 @@ +--- +title: SOLID +isChild: true +anchor: solid +--- + +## SOLID {#solid} + +SOLID is five design principles intended to make software designs more understandable, flexible and maintainable. + +### Single responsibility principle +> A class should only have a single responsibility, that is, only changes to one part of the software's specification should be able to affect the specification of the class. + +### Open–closed principle +> Software entities ... should be open for extension, but closed for modification. + +### Liskov substitution principle +> Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program. + +### Interface segregation principle +> Many client-specific interfaces are better than one general-purpose interface. + +### Dependency inversion principle +> One should depend upon abstractions, [not] concretions. \ No newline at end of file diff --git a/_posts/06-03-19-repository.md b/_posts/06-03-19-repository.md new file mode 100644 index 0000000..e17e74a --- /dev/null +++ b/_posts/06-03-19-repository.md @@ -0,0 +1,18 @@ +--- +title: Repository Pattern +isChild: true +anchor: solid +--- + +## Repository Pattern {#repository} + +The idea with this pattern is to have a generic abstract way for the app to work with the data layer without being bothered what storage technology is used when saving/retrieving the data. + +> We suggests to check first this [tutorial](https://medium.com/@jsdecena/refactor-the-simple-tdd-in-laravel-a92dd48f2cdd){:target="_blank"} for in-depth understand about this design pattern. + +### When reading/writing data, it is RECOMMENDED to wrap it into Repository Object + + +``` + +``` diff --git a/_posts/07-01-19-testing.md b/_posts/07-01-19-testing.md new file mode 100644 index 0000000..75aafca --- /dev/null +++ b/_posts/07-01-19-testing.md @@ -0,0 +1,5 @@ +--- +anchor: Testing +--- + +# Testing {#testing_title} \ No newline at end of file diff --git a/_posts/07-02-19-unit-tests.md b/_posts/07-02-19-unit-tests.md new file mode 100644 index 0000000..c9da8d5 --- /dev/null +++ b/_posts/07-02-19-unit-tests.md @@ -0,0 +1,30 @@ +--- +title: Unit Testing +isChild: true +anchor: unit-testing +--- + +## Unit Testing {#unit-testing} + + +### Methods in test classes MUST start with "test" then a camelCased name of the test + + +Good +``` +class ExampleTest extends TestCase +{ + public function testBasicTest() + { + +``` + +Bad + +``` +class ExampleTest extends TestCase +{ + public function test_basic_test() + { + +``` \ No newline at end of file diff --git a/_posts/07-03-19-integration-tests.md b/_posts/07-03-19-integration-tests.md new file mode 100644 index 0000000..940ac61 --- /dev/null +++ b/_posts/07-03-19-integration-tests.md @@ -0,0 +1,9 @@ +--- +title: Integration Tests +isChild: true +anchor: integration-tests +--- + +## Integration Tests {#integration-tests} + +> WIP (work in progress): this will be filled up by collected best practices once we had done enough research about the subject matter. \ No newline at end of file diff --git a/_posts/07-04-19-acceptance-tests.md b/_posts/07-04-19-acceptance-tests.md new file mode 100644 index 0000000..0a32c76 --- /dev/null +++ b/_posts/07-04-19-acceptance-tests.md @@ -0,0 +1,9 @@ +--- +title: Acceptance Tests +isChild: true +anchor: acceptance-tests +--- + +## Acceptance Tests {#acceptance-tests} + +> WIP (work in progress): this will be filled up by collected best practices once we had done enough research about the subject matter. \ No newline at end of file diff --git a/_posts/08-01-19-scalability.md b/_posts/08-01-19-scalability.md new file mode 100644 index 0000000..aba0da0 --- /dev/null +++ b/_posts/08-01-19-scalability.md @@ -0,0 +1,7 @@ +--- +anchor: Scalability +--- + +# Scalability {#scalability_title} + +> WIP (work in progress): this will be filled up by collected best practices once we had done enough research about the subject matter. \ No newline at end of file diff --git a/_posts/08-02-19-scale-up.md b/_posts/08-02-19-scale-up.md new file mode 100644 index 0000000..fde998a --- /dev/null +++ b/_posts/08-02-19-scale-up.md @@ -0,0 +1,9 @@ +--- +title: Scaling Up +isChild: true +anchor: Scaling Up +--- + +## Scaling Up {#scaling-up} + +> TODO \ No newline at end of file diff --git a/_posts/08-03-19-scale-out.md b/_posts/08-03-19-scale-out.md new file mode 100644 index 0000000..1c743dd --- /dev/null +++ b/_posts/08-03-19-scale-out.md @@ -0,0 +1,9 @@ +--- +title: Scaling Out +isChild: true +anchor: Scaling Out +--- + +## Scaling Out {#scaling-out} + +> TODO \ No newline at end of file diff --git a/_posts/08-04-19-microservices.md b/_posts/08-04-19-microservices.md new file mode 100644 index 0000000..7dede4d --- /dev/null +++ b/_posts/08-04-19-microservices.md @@ -0,0 +1,9 @@ +--- +title: Microservices +isChild: true +anchor: Microservices +--- + +## Microservices {#microservices} + +> WIP (work in progress): this will be filled up by collected best practices once we had done enough research about the subject matter. \ No newline at end of file diff --git a/_posts/09-01-19-resources.md b/_posts/09-01-19-resources.md new file mode 100644 index 0000000..a30de17 --- /dev/null +++ b/_posts/09-01-19-resources.md @@ -0,0 +1,7 @@ +--- +anchor: resources +--- + +# Resources {#resources_title} + +- [How to Hire a Great Laravel Developer](https://www.toptal.com/laravel#hiring-guide) \ No newline at end of file diff --git a/_posts/09-02-19-people-to-follow.md b/_posts/09-02-19-people-to-follow.md new file mode 100644 index 0000000..ede75da --- /dev/null +++ b/_posts/09-02-19-people-to-follow.md @@ -0,0 +1,17 @@ +--- +isChild: true +anchor: people_to_follow +--- + +## People to Follow {#people_to_follow_title} + +* [Taylor Otwell](https://twitter.com/taylorotwell){:target="_blank"} +* [Dayle Rees](https://twitter.com/daylerees){:target="_blank"} +* [Shawn McCool](https://twitter.com/ShawnMcCool){:target="_blank"} +* [Jeffrey Way](https://twitter.com/jeffrey_way){:target="_blank"} +* [Chris Fidao](https://twitter.com/fideloper){:target="_blank"} +* [Phil Sturgeon](https://twitter.com/philsturgeon){:target="_blank"} +* [Jens Segers](https://twitter.com/jenssegers){:target="_blank"} +* [Ben Corlett](https://twitter.com/ben_corlett){:target="_blank"} +* [Matt Stauffer](https://twitter.com/stauffermatt){:target="_blank"} +* [Graham Campbell](https://twitter.com/grahamjcampbell){:target="_blank"} diff --git a/_posts/09-03-19-mentoring.md b/_posts/09-03-19-mentoring.md new file mode 100644 index 0000000..6a61936 --- /dev/null +++ b/_posts/09-03-19-mentoring.md @@ -0,0 +1,9 @@ +--- +isChild: true +anchor: mentoring +--- + +## Mentoring {#mentoring_title} + +* [Laravel Forum](http://laravel.io/forum){:target="_blank"} - official forum and IRC channels for Laravel. +* [Laravel Recipes](http://laravel-recipes.com/){:target="_blank"} - useful tips and tutorials. \ No newline at end of file diff --git a/_posts/09-04-19-php-paas-providers.md b/_posts/09-04-19-php-paas-providers.md new file mode 100644 index 0000000..6a60405 --- /dev/null +++ b/_posts/09-04-19-php-paas-providers.md @@ -0,0 +1,13 @@ +--- +isChild: true +anchor: php_paas_providers +--- + +## PHP PaaS Providers {#php_paas_providers_title} + +* [Forge](https://forge.laravel.com/){:target="_blank"} +* [Fortrabbit](http://www.fortrabbit.com/){:target="_blank"} +* [PagodaBox](https://pagodabox.io/){:target="_blank"} +* [Heroku](https://www.heroku.com/){:target="_blank"} +* [Cloudways](https://www.cloudways.com/){:target="_blank"} +* [Liara](https://liara.ir/){:target="_blank"} \ No newline at end of file diff --git a/_posts/09-05-19-sites.md b/_posts/09-05-19-sites.md new file mode 100644 index 0000000..5bb43e3 --- /dev/null +++ b/_posts/09-05-19-sites.md @@ -0,0 +1,15 @@ +--- +isChild: true +anchor: other_resources +title: Other Useful Resources +--- + +## Other Useful Resources {#other_resources_title} + +### Laracasts + +* [Laracasts](https://laracasts.com/){:target="_blank"} + +### Starter Kits + +* [Laravel 5 Boilerplate with Gentelella Admin Theme](https://github.com/Labs64/laravel-boilerplate){:target="_blank"} diff --git a/_posts/16-09-01-Videos.md b/_posts/09-06-19-videos.md similarity index 50% rename from _posts/16-09-01-Videos.md rename to _posts/09-06-19-videos.md index 76ee740..8da2f5d 100644 --- a/_posts/16-09-01-Videos.md +++ b/_posts/09-06-19-videos.md @@ -6,11 +6,11 @@ title: Video Tutorials ### Youtube Channels -* [Laracon](https://www.youtube.com/channel/UCRawXmZv30Vf_MivyPYb_GQ) -* [Laracon EU](https://www.youtube.com/channel/UCb9XEo_1SDNR8Ucpbktrg5A) -* [php[architect]](https://www.youtube.com/channel/UCUEzH08rDNBfljD9PGVZujg) -* [phpacademy](https://www.youtube.com/user/phpacademy) +* [Laracon](https://www.youtube.com/channel/UCRawXmZv30Vf_MivyPYb_GQ){:target="_blank"} +* [Laracon EU](https://www.youtube.com/channel/UCb9XEo_1SDNR8Ucpbktrg5A){:target="_blank"} +* [php[architect]](https://www.youtube.com/channel/UCUEzH08rDNBfljD9PGVZujg){:target="_blank"} +* [phpacademy](https://www.youtube.com/user/phpacademy){:target="_blank"} ### Paid Videos -* open fo suggestions +* [Udemy - Laravel for beginners](https://www.udemy.com/php-with-laravel-for-beginners-become-a-master-in-laravel/){:target="_blank"} diff --git a/_posts/16-10-01-Books.md b/_posts/09-07-19-books.md similarity index 60% rename from _posts/16-10-01-Books.md rename to _posts/09-07-19-books.md index 7168084..81cf875 100644 --- a/_posts/16-10-01-Books.md +++ b/_posts/09-07-19-books.md @@ -5,13 +5,14 @@ anchor: books ## Books {#books_title} -* [**Laravel from Apprentice to Artisan** by Taylor Otwell](https://leanpub.com/laravel-testing-decoded) -* [**Laravel Testing Decoded** by Jeffrey Way](https://leanpub.com/laravel-testing-decoded) -* [**Implementing Laravel** by Chris Fidao](https://leanpub.com/implementinglaravel) -* [**Laravel Application Development Cookbook** by Terryu Matula](https://www.packtpub.com/web-development/laravel-application-development-cookbook) -* [**Laravel: Code Bright** by Dayle Rees](https://leanpub.com/codebright) -* [**Laravel 5 Essentials** by Martin Bean](https://www.packtpub.com/web-development/laravel-5-essentials) -* [Laravel Books on leanpub](https://leanpub.com/book_search?search=laravel) +* [**Laravel from Apprentice to Artisan** by Taylor Otwell](https://leanpub.com/laravel){:target="_blank"} +* [**Laravel Testing Decoded** by Jeffrey Way](https://leanpub.com/laravel-testing-decoded){:target="_blank"} +* [**Implementing Laravel** by Chris Fidao](https://leanpub.com/implementinglaravel){:target="_blank"} +* [**Laravel Application Development Cookbook** by Terryu Matula](https://www.packtpub.com/web-development/laravel-application-development-cookbook){:target="_blank"} +* [**Laravel: Code Bright** by Dayle Rees](https://leanpub.com/codebright){:target="_blank"} +* [**Laravel 5 Essentials** by Martin Bean](https://www.packtpub.com/web-development/laravel-5-essentials){:target="_blank"} +* [Laravel Books on leanpub](https://leanpub.com/book_search?search=laravel){:target="_blank"} +* [**Laravel: Up and Running** by Matt Stauffer](https://laravelupandrunning.com/){:target="_blank"} * open for suggestions diff --git a/_posts/09-08-19-frontend-development.md b/_posts/09-08-19-frontend-development.md new file mode 100644 index 0000000..05d70e2 --- /dev/null +++ b/_posts/09-08-19-frontend-development.md @@ -0,0 +1,40 @@ +--- +title: Frontend Development +isChild: true +anchor: frontend-development +--- + +## Frontend Development {#frontend_development} + +Laravel can use a variety of frontend javascript frameworks. It also provides for frontend presets (or ways to scaffold a frontend) which provides a basic starting point using [Bootstrap](https://getbootstrap.com/), [React](https://reactjs.org/), and / or [Vue](https://vuejs.org/). + +### Auth Scaffolding + +Starting in laravel 6, the artisan make:auth scaffolding has been moved to the `laravel/ui` package. + +### Generating scaffolding + +You can read more about generating scaffolding on the [docs/frontend](https://laravel.com/docs/7.x/frontend) page. + + +### Compiling Assets + +Everytime you add a new component to your app.js file, you need run `npm run dev` to compile the new component into javascript. To develop while automatically reloading your page everytime you change a frontend file, you can run `npm run watch`. For more information on how to configure laravel mix to compile different types of assets, please checkout the docs on [compiling assets](https://laravel.com/docs/7.x/mix#installation). + + +### CORS requests + +When developing a Single Page Application with laravel as the backend, you have to setup your middleware to accept [CORS request](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). Laravel 7 introduced [native support for CORS](https://laravel.com/docs/7.x/routing#cors), but if you are on an earlier version of laravel, you can use [spatie/laravel-cors](https://github.com/spatie/laravel-cors) to allow for requests to push through. You can learn about CORS [here](https://httptoolkit.tech/will-it-cors/). + +### CSRF Token + +When developing your [SPA](https://flaviocopes.com/single-page-application/), you may still want to secure your application's forms with Laravel's default CSRF Tokens. To do so, you'll need to attach the CSRF token to your form requests. You can do this by adding the value of the `X-XSRF-TOKEN` header. If you are building the SPA separately from your laravel app, you might want to use api-tokens instead. In Laravel 7, you can use [Laravel Sanctum's API Token Authentication](https://laravel.com/docs/7.x/sanctum#api-token-authentication) for this. + +### Additional Resources + +- [Video: Frontend Scaffolding Has Been Moved to Laravel UI](https://laracasts.com/series/whats-new-in-laravel-6/episodes/3) +- [Video: Learn Vue 2: Step By Step](https://laracasts.com/series/learn-vue-2-step-by-step) +- [Tutorial: Build authentication into your Laravel API with JSON Web Tokens (JWT)](https://medium.com/employbl/build-authentication-into-your-laravel-api-with-json-web-tokens-jwt-cd223ace8d1a) + + + diff --git a/_posts/10-01-19-community.md b/_posts/10-01-19-community.md new file mode 100644 index 0000000..63d0390 --- /dev/null +++ b/_posts/10-01-19-community.md @@ -0,0 +1,15 @@ +--- +anchor: community +--- + +# Community {#community_title} + +- [Twitter (@laravelphp)](https://twitter.com/laravelphp){:target="_blank"} +- [Slack (#laravel)](http://larachat.co/){:target="_blank"} +- [Reddit (/r/laravel)](https://reddit.com/r/laravel){:target="_blank"} +- [News](https://laravel-news.com/){:target="_blank"} +- [Laravel.io Forums](http://laravel.io/forum){:target="_blank"} +- [Laracasts Forums](https://laracasts.com/discuss){:target="_blank"} +- [Google+ Community](https://plus.google.com/communities/106838454910116161868){:target="_blank"} +- [Laravel Hunt](https://laravel-hunt.com){:target="_blank"} +- [Meetup](http://laravel.meetup.com/){:target="_blank"} diff --git a/_posts/17-03-01-Conferences.md b/_posts/10-02-19-conferences.md similarity index 58% rename from _posts/17-03-01-Conferences.md rename to _posts/10-02-19-conferences.md index c5f419d..4d237e6 100644 --- a/_posts/17-03-01-Conferences.md +++ b/_posts/10-02-19-conferences.md @@ -5,8 +5,8 @@ anchor: conferences ## Conferences {#conferences_title} -* [http://laracon.us][us-url] -* [http://laracon.eu][eu-url] +* [http://laracon.us][us-url]{:target="_blank"} +* [http://laracon.eu][eu-url]{:target="_blank"} [us-url]:http://laracon.us/ [eu-url]:http://laracon.eu/ diff --git a/_posts/10-02-19-user-groups.md b/_posts/10-02-19-user-groups.md new file mode 100644 index 0000000..3de841d --- /dev/null +++ b/_posts/10-02-19-user-groups.md @@ -0,0 +1,15 @@ +--- +isChild: true +anchor: user_groups +--- + +## User Groups {#user_groups_title} + +- [Laravel Philippines](https://www.facebook.com/groups/laravelph/){:target="_blank"} +- [Slack PHackers #LaravelPH](https://phackers.slack.com/messages/laravelph/){:target="_blank"} +- [Laravel Iran](http://laratalks.com){:target="_blank"} +- [Laravel India](https://www.facebook.com/groups/Laravel.Group.India/){:target="_blank"} +- [Laravel France](http://laravel.fr/){:target="_blank"} +- [Laravel Myanmar](http://laravelmyanmar.com/){:target="_blank"} +- [Laravel Spain](http://laraveles.com/foro/){:target="_blank"} +- [Laravel Korea](https://www.laravel.co.kr/){:target="_blank"} diff --git a/_posts/16-01-01-Resources.md b/_posts/16-01-01-Resources.md deleted file mode 100644 index 7747724..0000000 --- a/_posts/16-01-01-Resources.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -anchor: resources ---- - -# Resources {#resources_title} diff --git a/_posts/16-02-01-From-the-Source.md b/_posts/16-02-01-From-the-Source.md deleted file mode 100644 index 4e920db..0000000 --- a/_posts/16-02-01-From-the-Source.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -isChild: true -anchor: from_the_source ---- - -## From the Source {#from_the_source_title} - -* [Laravel Website](http://laravel.com/) -* [Laravel Documentation](http://laravel.com/docs) diff --git a/_posts/16-03-01-People-to-Follow.md b/_posts/16-03-01-People-to-Follow.md deleted file mode 100644 index ffa239f..0000000 --- a/_posts/16-03-01-People-to-Follow.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -isChild: true -anchor: people_to_follow ---- - -## People to Follow {#people_to_follow_title} - -* [Taylor Otwell](https://twitter.com/taylorotwell) -* [Dayle Rees](https://twitter.com/daylerees) -* [Shawn McCool](https://twitter.com/ShawnMcCool) -* [Jeffrey Way](https://twitter.com/jeffrey_way) -* [Chris Fidao](https://twitter.com/fideloper) -* [Phil Sturgeon](https://twitter.com/philsturgeon) -* [Jens Segers](https://twitter.com/jenssegers) -* [Ben Corlett](https://twitter.com/ben_corlett) -* [Matt Stauffer](https://twitter.com/stauffermatt) -* [Graham Campbell](https://twitter.com/grahamjcampbell) diff --git a/_posts/16-04-01-Mentoring.md b/_posts/16-04-01-Mentoring.md deleted file mode 100644 index ad0bb74..0000000 --- a/_posts/16-04-01-Mentoring.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -isChild: true -anchor: mentoring ---- - -## Mentoring {#mentoring_title} - -* [Laravel Forum](http://laravel.io/forum) - official forum and IRC channels for Laravel. -* [Laravel Recipes](http://laravel-recipes.com/) - useful tips and tutorials. \ No newline at end of file diff --git a/_posts/16-05-01-PHP-PaaS-Providers.md b/_posts/16-05-01-PHP-PaaS-Providers.md deleted file mode 100644 index 2a58880..0000000 --- a/_posts/16-05-01-PHP-PaaS-Providers.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -isChild: true -anchor: php_paas_providers ---- - -## PHP PaaS Providers {#php_paas_providers_title} - -* [Forge](https://forge.laravel.com/) -* [Fortrabbit](http://www.fortrabbit.com/) -* [PagodaBox](https://pagodabox.io/) -* [Heroku](https://www.heroku.com/) diff --git a/_posts/16-07-01-Components.md b/_posts/16-07-01-Components.md deleted file mode 100644 index 563a55e..0000000 --- a/_posts/16-07-01-Components.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -isChild: true -anchor: components ---- - -## Components {#components_title} - -Illuminate components which can be found in -https://github.com/illuminate - -are the smaller parts that makes up Laravel Framework. -Several other open-source libraries can be also seen to be used by Laravel by mere looking at its composer.json file -https://github.com/laravel/framework/blob/5.0/composer.json#L22-L43 diff --git a/_posts/16-08-01-Sites.md b/_posts/16-08-01-Sites.md deleted file mode 100644 index 8a9a994..0000000 --- a/_posts/16-08-01-Sites.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -isChild: true -anchor: other_resources -title: Other Useful Resources ---- - -## Other Useful Resources {#other_resources_title} - -### Laracasts - -* [Laracasts](https://laracasts.com/) \ No newline at end of file diff --git a/_posts/17-01-01-Community.md b/_posts/17-01-01-Community.md deleted file mode 100644 index a2e9d47..0000000 --- a/_posts/17-01-01-Community.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -anchor: community ---- - -# Community {#community_title} - -- [Twitter (@laravelphp)](https://twitter.com/laravelphp) -- [Slack (#laravel)](http://larachat.co/) -- [Reddit (/r/laravel)](https://reddit.com/r/laravel) -- [News](https://laravel-news.com/) -- [Laravel.io Forums](http://laravel.io/forum) -- [Laracasts Forums](https://laracasts.com/discuss) -- [Google+ Community](https://plus.google.com/communities/106838454910116161868) -- [Laravel Hunt](https://laravel-hunt.com) -- [Meetup](http://laravel.meetup.com/) diff --git a/_posts/17-02-01-User-Groups.md b/_posts/17-02-01-User-Groups.md deleted file mode 100644 index 3b604a0..0000000 --- a/_posts/17-02-01-User-Groups.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -isChild: true -anchor: user_groups ---- - -## User Groups {#user_groups_title} - -- [Laravel Philippines](https://www.facebook.com/groups/laravelph/) -- [Slack PHackers #LaravelPH](https://phackers.slack.com/messages/laravelph/) -- [Laravel Iran](http://laratalks.com) -- [Laravel India](https://www.facebook.com/groups/Laravel.Group.India/) -- [Laravel France](http://laravel.fr/) -- [Laravel Myanmar](http://laravelmyanmar.com/) -- [Laravel Spain](http://laraveles.com/foro/) -- [Laravel Korea](https://www.laravel.co.kr/) diff --git a/ads.txt b/ads.txt new file mode 100644 index 0000000..b436a99 --- /dev/null +++ b/ads.txt @@ -0,0 +1,13 @@ +media.net, 8CU856K4B, DIRECT +rubiconproject.com, 19398, DIRECT, 0bfd66d529a55807 +rubiconproject.com, 19398, RESELLER, 0bfd66d529a55807 +pubmatic.com, 157599, DIRECT, 5d62403b186f2ace +pubmatic.com, 157599, RESELLER, 5d62403b186f2ace +openx.com, 537100188, RESELLER, 6a698e2ec38604c6 +google.com, pub-7439041255533808, RESELLER, f08c47fec0942fa0 +districtm.io, 100600, DIRECT +rubiconproject.com, 17054, RESELLER +pubmatic.com, 156181, RESELLER +spotxchange.com, 211156, RESELLER, 7842df1d2fe2db34 +spotx.tv, 211156, RESELLER, 7842df1d2fe2db34 +google.com, pub-0845730634111642, DIRECT, f08c47fec0942fa0 \ No newline at end of file diff --git a/android-icon-144x144.png b/android-icon-144x144.png new file mode 100644 index 0000000..a2aa90e Binary files /dev/null and b/android-icon-144x144.png differ diff --git a/android-icon-192x192.png b/android-icon-192x192.png new file mode 100644 index 0000000..8d50206 Binary files /dev/null and b/android-icon-192x192.png differ diff --git a/android-icon-36x36.png b/android-icon-36x36.png new file mode 100644 index 0000000..dbe1eaa Binary files /dev/null and b/android-icon-36x36.png differ diff --git a/android-icon-48x48.png b/android-icon-48x48.png new file mode 100644 index 0000000..207212d Binary files /dev/null and b/android-icon-48x48.png differ diff --git a/android-icon-72x72.png b/android-icon-72x72.png new file mode 100644 index 0000000..a52582a Binary files /dev/null and b/android-icon-72x72.png differ diff --git a/android-icon-96x96.png b/android-icon-96x96.png new file mode 100644 index 0000000..8d06447 Binary files /dev/null and b/android-icon-96x96.png differ diff --git a/apple-icon-114x114.png b/apple-icon-114x114.png new file mode 100644 index 0000000..f00c3d1 Binary files /dev/null and b/apple-icon-114x114.png differ diff --git a/apple-icon-120x120.png b/apple-icon-120x120.png new file mode 100644 index 0000000..c8ce894 Binary files /dev/null and b/apple-icon-120x120.png differ diff --git a/apple-icon-144x144.png b/apple-icon-144x144.png new file mode 100644 index 0000000..a2aa90e Binary files /dev/null and b/apple-icon-144x144.png differ diff --git a/apple-icon-152x152.png b/apple-icon-152x152.png new file mode 100644 index 0000000..ec0feef Binary files /dev/null and b/apple-icon-152x152.png differ diff --git a/apple-icon-180x180.png b/apple-icon-180x180.png new file mode 100644 index 0000000..3f30732 Binary files /dev/null and b/apple-icon-180x180.png differ diff --git a/apple-icon-57x57.png b/apple-icon-57x57.png new file mode 100644 index 0000000..d5041c4 Binary files /dev/null and b/apple-icon-57x57.png differ diff --git a/apple-icon-60x60.png b/apple-icon-60x60.png new file mode 100644 index 0000000..243452d Binary files /dev/null and b/apple-icon-60x60.png differ diff --git a/apple-icon-72x72.png b/apple-icon-72x72.png new file mode 100644 index 0000000..a52582a Binary files /dev/null and b/apple-icon-72x72.png differ diff --git a/apple-icon-76x76.png b/apple-icon-76x76.png new file mode 100644 index 0000000..dfd02a3 Binary files /dev/null and b/apple-icon-76x76.png differ diff --git a/apple-icon-precomposed.png b/apple-icon-precomposed.png new file mode 100644 index 0000000..7eb8daa Binary files /dev/null and b/apple-icon-precomposed.png differ diff --git a/apple-icon.png b/apple-icon.png new file mode 100644 index 0000000..7eb8daa Binary files /dev/null and b/apple-icon.png differ diff --git a/browserconfig.xml b/browserconfig.xml new file mode 100644 index 0000000..c554148 --- /dev/null +++ b/browserconfig.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig> \ No newline at end of file diff --git a/favicon-16x16.png b/favicon-16x16.png new file mode 100644 index 0000000..cd057d7 Binary files /dev/null and b/favicon-16x16.png differ diff --git a/favicon-32x32.png b/favicon-32x32.png new file mode 100644 index 0000000..d98b978 Binary files /dev/null and b/favicon-32x32.png differ diff --git a/favicon-96x96.png b/favicon-96x96.png new file mode 100644 index 0000000..8d06447 Binary files /dev/null and b/favicon-96x96.png differ diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..436e97e Binary files /dev/null and b/favicon.ico differ diff --git a/feed.xml b/feed.xml new file mode 100644 index 0000000..6c61fab --- /dev/null +++ b/feed.xml @@ -0,0 +1,30 @@ +--- +layout: null +--- +<?xml version="1.0" encoding="UTF-8"?> +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> + <channel> + <title>{{ site.title | xml_escape }}</title> + <description>{{ site.description | xml_escape }}</description> + <link>{{ site.url }}{{ site.baseurl }}/</link> + <atom:link href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" rel="self" type="application/rss+xml" /> + <pubDate>{{ site.time | date_to_rfc822 }}</pubDate> + <lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate> + <generator>Jekyll v{{ jekyll.version }}</generator> + {% for post in site.posts limit:100 %} + <item> + <title>{{ post.title | xml_escape }}</title> + <description>{{ post.content | xml_escape }}</description> + <pubDate>{{ post.date | date_to_rfc822 }}</pubDate> + <link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link> + <guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid> + {% for tag in post.tags %} + <category>{{ tag | xml_escape }}</category> + {% endfor %} + {% for cat in post.categories %} + <category>{{ cat | xml_escape }}</category> + {% endfor %} + </item> + {% endfor %} + </channel> +</rss> \ No newline at end of file diff --git a/images/Laravel-Servers-Architecture.jpg b/images/Laravel-Servers-Architecture.jpg new file mode 100644 index 0000000..afe7aef Binary files /dev/null and b/images/Laravel-Servers-Architecture.jpg differ diff --git a/images/favicon.png b/images/favicon.png index e337b25..6a013e8 100755 Binary files a/images/favicon.png and b/images/favicon.png differ diff --git a/images/get-it-on-google-play-icon-logo.png b/images/get-it-on-google-play-icon-logo.png new file mode 100644 index 0000000..c303db7 Binary files /dev/null and b/images/get-it-on-google-play-icon-logo.png differ diff --git a/images/og-logo.png b/images/og-logo.png old mode 100755 new mode 100644 index 65334fd..59340ac Binary files a/images/og-logo.png and b/images/og-logo.png differ diff --git a/images/play-banner1.jpg b/images/play-banner1.jpg new file mode 100644 index 0000000..44ff144 Binary files /dev/null and b/images/play-banner1.jpg differ diff --git a/images/play-banner2.jpg b/images/play-banner2.jpg new file mode 100644 index 0000000..518f1ce Binary files /dev/null and b/images/play-banner2.jpg differ diff --git a/images/play-banner3.png b/images/play-banner3.png new file mode 100644 index 0000000..43bbbd4 Binary files /dev/null and b/images/play-banner3.png differ diff --git a/images/polyglot.png b/images/polyglot.png new file mode 100644 index 0000000..e77b6af Binary files /dev/null and b/images/polyglot.png differ diff --git a/images/res/mipmap-hdpi/ic_launcher.png b/images/res/mipmap-hdpi/ic_launcher.png new file mode 100755 index 0000000..512cb1c Binary files /dev/null and b/images/res/mipmap-hdpi/ic_launcher.png differ diff --git a/images/res/mipmap-mdpi/ic_launcher.png b/images/res/mipmap-mdpi/ic_launcher.png new file mode 100755 index 0000000..06d95c9 Binary files /dev/null and b/images/res/mipmap-mdpi/ic_launcher.png differ diff --git a/images/res/mipmap-xhdpi/ic_launcher.png b/images/res/mipmap-xhdpi/ic_launcher.png new file mode 100755 index 0000000..ac36c70 Binary files /dev/null and b/images/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/images/res/mipmap-xxhdpi/ic_launcher.png b/images/res/mipmap-xxhdpi/ic_launcher.png new file mode 100755 index 0000000..aecfe86 Binary files /dev/null and b/images/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/images/res/mipmap-xxxhdpi/ic_launcher.png b/images/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100755 index 0000000..6a013e8 Binary files /dev/null and b/images/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/images/web_hi_res_512.png b/images/web_hi_res_512.png new file mode 100755 index 0000000..695cc28 Binary files /dev/null and b/images/web_hi_res_512.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..013d4a6 --- /dev/null +++ b/manifest.json @@ -0,0 +1,41 @@ +{ + "name": "App", + "icons": [ + { + "src": "\/android-icon-36x36.png", + "sizes": "36x36", + "type": "image\/png", + "density": "0.75" + }, + { + "src": "\/android-icon-48x48.png", + "sizes": "48x48", + "type": "image\/png", + "density": "1.0" + }, + { + "src": "\/android-icon-72x72.png", + "sizes": "72x72", + "type": "image\/png", + "density": "1.5" + }, + { + "src": "\/android-icon-96x96.png", + "sizes": "96x96", + "type": "image\/png", + "density": "2.0" + }, + { + "src": "\/android-icon-144x144.png", + "sizes": "144x144", + "type": "image\/png", + "density": "3.0" + }, + { + "src": "\/android-icon-192x192.png", + "sizes": "192x192", + "type": "image\/png", + "density": "4.0" + } + ] +} \ No newline at end of file diff --git a/ms-icon-144x144.png b/ms-icon-144x144.png new file mode 100644 index 0000000..a2aa90e Binary files /dev/null and b/ms-icon-144x144.png differ diff --git a/ms-icon-150x150.png b/ms-icon-150x150.png new file mode 100644 index 0000000..0a24ec4 Binary files /dev/null and b/ms-icon-150x150.png differ diff --git a/ms-icon-310x310.png b/ms-icon-310x310.png new file mode 100644 index 0000000..1c48344 Binary files /dev/null and b/ms-icon-310x310.png differ diff --git a/ms-icon-70x70.png b/ms-icon-70x70.png new file mode 100644 index 0000000..6a30557 Binary files /dev/null and b/ms-icon-70x70.png differ diff --git a/pages/Design-Patterns.md b/pages/Design-Patterns.md deleted file mode 100644 index 231eccc..0000000 --- a/pages/Design-Patterns.md +++ /dev/null @@ -1,273 +0,0 @@ ---- -layout: page -title: Design Patterns -sitemap: true ---- - -# Design Patterns - -There are numerous ways to structure the code and project for your web application, and you can put as much or as little thought as you like into architecting. But it is usually a good idea to follow common patterns because it will -make your code easier to manage and easier for others to understand. - -* [Architectural pattern on Wikipedia](https://en.wikipedia.org/wiki/Architectural_pattern) -* [Software design pattern on Wikipedia](https://en.wikipedia.org/wiki/Software_design_pattern) -* [Collection of implementation examples](https://github.com/domnikl/DesignPatternsPHP) - -## Factory - -One of the most commonly used design patterns is the factory pattern. In this pattern, a class simply creates the -object you want to use. Consider the following example of the factory pattern: - -{% highlight php %} -<?php -class Automobile -{ - private $vehicleMake; - private $vehicleModel; - - public function __construct($make, $model) - { - $this->vehicleMake = $make; - $this->vehicleModel = $model; - } - - public function getMakeAndModel() - { - return $this->vehicleMake . ' ' . $this->vehicleModel; - } -} - -class AutomobileFactory -{ - public static function create($make, $model) - { - return new Automobile($make, $model); - } -} - -// have the factory create the Automobile object -$veyron = AutomobileFactory::create('Bugatti', 'Veyron'); - -print_r($veyron->getMakeAndModel()); // outputs "Bugatti Veyron" -{% endhighlight %} - -This code uses a factory to create the Automobile object. There are two possible benefits to building your code this -way; the first is that if you need to change, rename, or replace the Automobile class later on you can do so and you -will only have to modify the code in the factory, instead of every place in your project that uses the Automobile class. -The second possible benefit is that if creating the object is a complicated job you can do all of the work in the -factory, instead of repeating it every time you want to create a new instance. - -Using the factory pattern isn't always necessary (or wise). The example code used here is so simple that a factory -would simply be adding unneeded complexity. However if you are making a fairly large or complex project you may save -yourself a lot of trouble down the road by using factories. - -* [Factory pattern on Wikipedia](https://en.wikipedia.org/wiki/Factory_pattern) - -## Singleton - -When designing web applications, it often makes sense conceptually and architecturally to allow access to one and only -one instance of a particular class. The singleton pattern enables us to do this. - -{% highlight php %} -<?php -class Singleton -{ - /** - * Returns the *Singleton* instance of this class. - * - * @staticvar Singleton $instance The *Singleton* instances of this class. - * - * @return Singleton The *Singleton* instance. - */ - public static function getInstance() - { - static $instance = null; - if (null === $instance) { - $instance = new static(); - } - - return $instance; - } - - /** - * Protected constructor to prevent creating a new instance of the - * *Singleton* via the `new` operator from outside of this class. - */ - protected function __construct() - { - } - - /** - * Private clone method to prevent cloning of the instance of the - * *Singleton* instance. - * - * @return void - */ - private function __clone() - { - } - - /** - * Private unserialize method to prevent unserializing of the *Singleton* - * instance. - * - * @return void - */ - private function __wakeup() - { - } -} - -class SingletonChild extends Singleton -{ -} - -$obj = Singleton::getInstance(); -var_dump($obj === Singleton::getInstance()); // bool(true) - -$anotherObj = SingletonChild::getInstance(); -var_dump($anotherObj === Singleton::getInstance()); // bool(false) - -var_dump($anotherObj === SingletonChild::getInstance()); // bool(true) -{% endhighlight %} - -The code above implements the singleton pattern using a [*static* variable](http://php.net/language.variables.scope#language.variables.scope.static) and the static creation method `getInstance()`. -Note the following: - -* The constructor [`__construct()`](http://php.net/language.oop5.decon#object.construct) is declared as protected to -prevent creating a new instance outside of the class via the `new` operator. -* The magic method [`__clone()`](http://php.net/language.oop5.cloning#object.clone) is declared as private to prevent -cloning of an instance of the class via the [`clone`](http://php.net/language.oop5.cloning) operator. -* The magic method [`__wakeup()`](http://php.net/language.oop5.magic#object.wakeup) is declared as private to prevent -unserializing of an instance of the class via the global function [`unserialize()`](http://php.net/function.unserialize) -. -* A new instance is created via [late static binding](http://php.net/language.oop5.late-static-bindings) in the static -creation method `getInstance()` with the keyword `static`. This allows the subclassing of the class `Singleton` in the -example. - -The singleton pattern is useful when we need to make sure we only have a single instance of a class for the entire -request lifecycle in a web application. This typically occurs when we have global objects (such as a Configuration -class) or a shared resource (such as an event queue). - -You should be wary when using the singleton pattern, as by its very nature it introduces global state into your -application, reducing testability. In most cases, dependency injection can (and should) be used in place of a singleton -class. Using dependency injection means that we do not introduce unnecessary coupling into the design of our -application, as the object using the shared or global resource requires no knowledge of a concretely defined class. - -* [Singleton pattern on Wikipedia](https://en.wikipedia.org/wiki/Singleton_pattern) - -## Strategy - -With the strategy pattern you encapsulate specific families of algorithms allowing the client class responsible for -instantiating a particular algorithm to have no knowledge of the actual implementation. There are several variations on -the strategy pattern, the simplest of which is outlined below: - -This first code snippet outlines a family of algorithms; you may want a serialized array, some JSON or maybe just an -array of data: - -{% highlight php %} -<?php - -interface OutputInterface -{ - public function load(); -} - -class SerializedArrayOutput implements OutputInterface -{ - public function load() - { - return serialize($arrayOfData); - } -} - -class JsonStringOutput implements OutputInterface -{ - public function load() - { - return json_encode($arrayOfData); - } -} - -class ArrayOutput implements OutputInterface -{ - public function load() - { - return $arrayOfData; - } -} -{% endhighlight %} - -By encapsulating the above algorithms you are making it nice and clear in your code that other developers can easily -add new output types without affecting the client code. - -You will see how each concrete 'output' class implements an OutputInterface - this serves two purposes, primarily it -provides a simple contract which must be obeyed by any new concrete implementations. Secondly by implementing a common -interface you will see in the next section that you can now utilise [Type Hinting](http://php.net/language.oop5.typehinting) to ensure that the client which is utilising these behaviours is of the correct type in -this case 'OutputInterface'. - -The next snippet of code outlines how a calling client class might use one of these algorithms and even better set the -behaviour required at runtime: - -{% highlight php %} -<?php -class SomeClient -{ - private $output; - - public function setOutput(OutputInterface $outputType) - { - $this->output = $outputType; - } - - public function loadOutput() - { - return $this->output->load(); - } -} -{% endhighlight %} - -The calling client class above has a private property which must be set at runtime and be of type 'OutputInterface' -once this property is set a call to loadOutput() will call the load() method in the concrete class of the output type -that has been set. - -{% highlight php %} -<?php -$client = new SomeClient(); - -// Want an array? -$client->setOutput(new ArrayOutput()); -$data = $client->loadOutput(); - -// Want some JSON? -$client->setOutput(new JsonStringOutput()); -$data = $client->loadOutput(); - -{% endhighlight %} - -* [Strategy pattern on Wikipedia](http://en.wikipedia.org/wiki/Strategy_pattern) - -## Front Controller - -The front controller pattern is where you have a single entrance point for you web application (e.g. index.php) that -handles all of the requests. This code is responsible for loading all of the dependencies, processing the request and -sending the response to the browser. The front controller pattern can be beneficial because it encourages modular code -and gives you a central place to hook in code that should be run for every request (such as input sanitization). - -* [Front Controller pattern on Wikipedia](https://en.wikipedia.org/wiki/Front_Controller_pattern) - -## Model-View-Controller - -The model-view-controller (MVC) pattern and its relatives HMVC and MVVM lets you break up code into logical objects -that serve very specific purposes. Models serve as a data access layer where data is fetched and returned in formats -usable throughout your application. Controllers handle the request, process the data returned from models and load -views to send in the response. And views are display templates (markup, xml, etc) that are sent in the response to the -web browser. - -MVC is the most common architectural pattern used in the popular [PHP frameworks](https://github.com/codeguy/php-the-right-way/wiki/Frameworks). - -Learn more about MVC and its relatives: - -* [MVC](https://en.wikipedia.org/wiki/Model%E2%80%93View%E2%80%93Controller) -* [HMVC](https://en.wikipedia.org/wiki/Hierarchical_model%E2%80%93view%E2%80%93controller) -* [MVVM](https://en.wikipedia.org/wiki/Model_View_ViewModel) diff --git a/pages/Functional-Programming.md b/pages/Functional-Programming.md deleted file mode 100644 index 85bb97f..0000000 --- a/pages/Functional-Programming.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -layout: page -title: Functional Programming in PHP -sitemap: true ---- - -# Functional Programming in PHP - -PHP supports first-class functions, meaning that a function can be assigned to a variable. Both user-defined and -built-in functions can be referenced by a variable and invoked dynamically. Functions can be passed as arguments to -other functions and a function can return other functions (a feature called higher-order functions). - -Recursion, a feature that allows a function to call itself, is supported by the language, but most of the PHP code -focus is on iteration. - -Anonymous functions (with support for closures) have been present since PHP 5.3 (2009). - -PHP 5.4 added the ability to bind closures to an object's scope and also improved support for callables such that they -can be used interchangeably with anonymous functions in almost all cases. - -The most common usage of higher-order functions is when implementing a strategy pattern. The built-in `array_filter()` -function asks both for the input array (data) and a function (a strategy or a callback) used as a filter function on -each array item. - -{% highlight php %} -<?php -$input = array(1, 2, 3, 4, 5, 6); - -// Creates a new anonymous function and assigns it to a variable -$filter_even = function($item) { - return ($item % 2) == 0; -}; - -// Built-in array_filter accepts both the data and the function -$output = array_filter($input, $filter_even); - -// The function doesn't need to be assigned to a variable. This is valid too: -$output = array_filter($input, function($item) { - return ($item % 2) == 0; -}); - -print_r($output); -{% endhighlight %} - -A closure is an anonymous function that can access variables imported from the outside scope without using any global -variables. Theoretically, a closure is a function with some arguments closed (e.g. fixed) by the environment when it is -defined. Closures can work around variable scope restrictions in a clean way. - -In the next example we use closures to define a function returning a single filter function for `array_filter()`, out -of a family of filter functions. - -{% highlight php %} -<?php -/** - * Creates an anonymous filter function accepting items > $min - * - * Returns a single filter out of a family of "greater than n" filters - */ -function criteria_greater_than($min) -{ - return function($item) use ($min) { - return $item > $min; - }; -} - -$input = array(1, 2, 3, 4, 5, 6); - -// Use array_filter on a input with a selected filter function -$output = array_filter($input, criteria_greater_than(3)); - -print_r($output); // items > 3 -{% endhighlight %} - -Each filter function in the family accepts only elements greater than some minimum value. Single filter returned by -`criteria_greater_than` is a closure with `$min` argument closed by the value in the scope (given as an argument when -`criteria_greater_than` is called). - -Early binding is used by default for importing `$min` variable into the created function. For true closures with late -binding one should use a reference when importing. Imagine a templating or input validation library, where closure is -defined to capture variables in scope and access them later when the anonymous function is evaluated. - -* [Read about Anonymous functions][anonymous-functions] -* [More details in the Closures RFC][closures-rfc] -* [Read about dynamically invoking functions with `call_user_func_array()`][call-user-func-array] - - -[anonymous-functions]: http://php.net/functions.anonymous -[closures-rfc]: https://wiki.php.net/rfc/closures -[call-user-func-array]: http://php.net/function.call-user-func-array diff --git a/pages/The-Basics.md b/pages/The-Basics.md deleted file mode 100644 index 782a734..0000000 --- a/pages/The-Basics.md +++ /dev/null @@ -1,406 +0,0 @@ ---- -layout: page -title: The Basics -sitemap: true ---- - -# The Basics - -## Comparison operators - -Comparison operators are an often overlooked aspect of PHP, which can lead to many unexpected outcomes. One such -problem stems from strict comparisons (the comparison of booleans as integers). - -{% highlight php %} -<?php -$a = 5; // 5 as an integer - -var_dump($a == 5); // compare value; return true -var_dump($a == '5'); // compare value (ignore type); return true -var_dump($a === 5); // compare type/value (integer vs. integer); return true -var_dump($a === '5'); // compare type/value (integer vs. string); return false - -/** - * Strict comparisons - */ -if (strpos('testing', 'test')) { // 'test' is found at position 0, which is interpreted as the boolean 'false' - // code... -} - -// vs - -if (strpos('testing', 'test') !== false) { // true, as strict comparison was made (0 !== false) - // code... -} -{% endhighlight %} - -* [Comparison operators](http://php.net/language.operators.comparison) -* [Comparison table](http://php.net/types.comparisons) -* [Comparison cheatsheet](http://phpcheatsheets.com/index.php?page=compare) - -## Conditional statements - -### If statements - -While using 'if/else' statements within a function or class, there is a common misconception that 'else' must be used -in conjunction to declare potential outcomes. However if the outcome is to define the return value, 'else' is not -necessary as 'return' will end the function, causing 'else' to become moot. - -{% highlight php %} -<?php -function test($a) -{ - if ($a) { - return true; - } else { - return false; - } -} - -// vs - -function test($a) -{ - if ($a) { - return true; - } - return false; // else is not necessary -} -{% endhighlight %} - -* [If statements](http://php.net/control-structures.if) - -### Switch statements - -Switch statements are a great way to avoid typing endless if's and elseif's, but there are a few things to be aware of: - -- Switch statements only compare values, and not the type (equivalent to '==') -- They Iterate case by case until a match is found. If no match is found, then the default is used (if defined) -- Without a 'break', they will continue to implement each case until reaching a break/return -- Within a function, using 'return' alleviates the need for 'break' as it ends the function - -{% highlight php %} -<?php -$answer = test(2); // the code from both 'case 2' and 'case 3' will be implemented - -function test($a) -{ - switch ($a) { - case 1: - // code... - break; // break is used to end the switch statement - case 2: - // code... // with no break, comparison will continue to 'case 3' - case 3: - // code... - return $result; // within a function, 'return' will end the function - default: - // code... - return $error; - } -} -{% endhighlight %} - -* [Switch statements](http://php.net/control-structures.switch) -* [PHP switch](http://phpswitch.com/) - -## Global namespace - -When using namespaces, you may find that internal functions are hidden by functions you wrote. To fix this, refer to -the global function by using a backslash before the function name. - -{% highlight php %} -<?php -namespace phptherightway; - -function fopen() -{ - $file = \fopen(); // Our function name is the same as an internal function. - // Execute the function from the global space by adding '\'. -} - -function array() -{ - $iterator = new \ArrayIterator(); // ArrayIterator is an internal class. Using its name without a backslash - // will attempt to resolve it within your namespace. -} -{% endhighlight %} - -* [Global space](http://php.net/language.namespaces.global) -* [Global rules](http://php.net/userlandnaming.rules) - -## Strings - -### Concatenation - -- If your line extends beyond the recommended line length (120 characters), consider concatenating your line -- For readability it is best to use concatenation operators over concatenating assignment operators -- While within the original scope of the variable, indent when concatenation uses a new line - - -{% highlight php %} -<?php -$a = 'Multi-line example'; // concatenating assignment operator (.=) -$a .= "\n"; -$a .= 'of what not to do'; - -// vs - -$a = 'Multi-line example' // concatenation operator (.) - . "\n" // indenting new lines - . 'of what to do'; -{% endhighlight %} - -* [String Operators](http://php.net/language.operators.string) - -### String types - -Strings are a series of characters, which should sound fairly simple. That said, there are a few different types of -strings and they offer slightly different syntax, with slightly different behaviors. - -#### Single quotes - -Single quotes are used to denote a "literal string". Literal strings do not attempt to parse special characters or -variables. - -If using single quotes, you could enter a variable name into a string like so: `'some $thing'`, and you would see the -exact output of `some $thing`. If using double quotes, that would try to evaluate the `$thing` variable name and show -errors if no variable was found. - - -{% highlight php %} -<?php -echo 'This is my string, look at how pretty it is.'; // no need to parse a simple string - -/** - * Output: - * - * This is my string, look at how pretty it is. - */ -{% endhighlight %} - -* [Single quote](http://php.net/language.types.string#language.types.string.syntax.single) - -#### Double quotes - -Double quotes are the Swiss Army Knife of strings. They will not only parse variables as mentioned above, but all sorts -of special characters, like `\n` for newline, `\t` for a tab, etc. - -{% highlight php %} -<?php -echo 'phptherightway is ' . $adjective . '.' // a single quotes example that uses multiple concatenating for - . "\n" // variables and escaped string - . 'I love learning' . $code . '!'; - -// vs - -echo "phptherightway is $adjective.\n I love learning $code!" // Instead of multiple concatenating, double quotes - // enables us to use a parsable string -{% endhighlight %} - -Double quotes can contain variables; this is called "interpolation". - -{% highlight php %} -<?php -$juice = 'plum'; -echo "I like $juice juice"; // Output: I like plum juice -{% endhighlight %} - -When using interpolation, it is often the case that the variable will be touching another character. This will result -in some confusion as to what is the name of the variable, and what is a literal character. - -To fix this problem, wrap the variable within a pair of curly brackets. - -{% highlight php %} -<?php -$juice = 'plum'; -echo "I drank some juice made of $juices"; // $juice cannot be parsed - -// vs - -$juice = 'plum'; -echo "I drank some juice made of {$juice}s"; // $juice will be parsed - -/** - * Complex variables will also be parsed within curly brackets - */ - -$juice = array('apple', 'orange', 'plum'); -echo "I drank some juice made of {$juice[1]}s"; // $juice[1] will be parsed -{% endhighlight %} - -* [Double quotes](http://php.net/language.types.string#language.types.string.syntax.double) - -#### Nowdoc syntax - -Nowdoc syntax was introduced in 5.3 and internally behaves the same way as single quotes except it is suited toward the -use of multi-line strings without the need for concatenating. - -{% highlight php %} -<?php -$str = <<<'EOD' // initialized by <<< -Example of string -spanning multiple lines -using nowdoc syntax. -$a does not parse. -EOD; // closing 'EOD' must be on it's own line, and to the left most point - -/** - * Output: - * - * Example of string - * spanning multiple lines - * using nowdoc syntax. - * $a does not parse. - */ -{% endhighlight %} - -* [Nowdoc syntax](http://php.net/language.types.string#language.types.string.syntax.nowdoc) - -#### Heredoc syntax - -Heredoc syntax internally behaves the same way as double quotes except it is suited toward the use of multi-line -strings without the need for concatenating. - -{% highlight php %} -<?php -$a = 'Variables'; - -$str = <<<EOD // initialized by <<< -Example of string -spanning multiple lines -using heredoc syntax. -$a are parsed. -EOD; // closing 'EOD' must be on it's own line, and to the left most point - -/** - * Output: - * - * Example of string - * spanning multiple lines - * using heredoc syntax. - * Variables are parsed. - */ -{% endhighlight %} - -* [Heredoc syntax](http://php.net/language.types.string#language.types.string.syntax.heredoc) - -### Which is quicker? - -There is a myth floating around that single quote strings are fractionally quicker than double quote strings. This is -fundamentally not true. - -If you are defining a single string and not trying to concatenate values or anything complicated, then either a single -or double quoted string will be entirely identical. Neither are quicker. - -If you are concatenating multiple strings of any type, or interpolate values into a double quoted string, then the -results can vary. If you are working with a small number of values, concatenation is minutely faster. With a lot of -values, interpolating is minutely faster. - -Regardless of what you are doing with strings, none of the types will ever have any noticable impact on your -application. Trying to rewrite code to use one or the other is always an exercise in futility, so avoid this micro- -optimization unless you really understand the meaning and impact of the differences. - -* [Disproving the Single Quotes Performance Myth](http://nikic.github.io/2012/01/09/Disproving-the-Single-Quotes-Performance-Myth.html) - - -## Ternary operators - -Ternary operators are a great way to condense code, but are often used in excess. While ternary operators can be -stacked/nested, it is advised to use one per line for readability. - -{% highlight php %} -<?php -$a = 5; -echo ($a == 5) ? 'yay' : 'nay'; -{% endhighlight %} - -In comparison, here is an example that sacrifices all forms of readability for the sake of reducing the line count. - -{% highlight php %} -<?php -echo ($a) ? ($a == 5) ? 'yay' : 'nay' : ($b == 10) ? 'excessive' : ':('; // excess nesting, sacrificing readability -{% endhighlight %} - -To 'return' a value with ternary operators use the correct syntax. - -{% highlight php %} -<?php -$a = 5; -echo ($a == 5) ? return true : return false; // this example will output an error - -// vs - -$a = 5; -return ($a == 5) ? 'yay' : 'nope'; // this example will return 'yay' - -{% endhighlight %} - -It should be noted that you do not need to use a ternary operator for returning a boolean value. An example of this -would be. - -{% highlight php %} -<?php -$a = 3; -return ($a == 3) ? true : false; // Will return true or false if $a == 3 - -// vs - -$a = 3; -return $a == 3; // Will return true or false if $a == 3 - -{% endhighlight %} - -This can also be said for all operations(===, !==, !=, == etc). - -#### Utilising brackets with ternary operators for form and function - -When utilising a ternary operator, brackets can play their part to improve code readability and also to include unions -within blocks of statements. An example of when there is no requirement to use bracketing is: - -{% highlight php %} -<?php -$a = 3; -return ($a == 3) ? "yay" : "nope"; // return yay or nope if $a == 3 - -// vs - -$a = 3; -return $a == 3 ? "yay" : "nope"; // return yay or nope if $a == 3 -{% endhighlight %} - -Bracketing also affords us the capability of creating unions within a statement block where the block will be checked -as a whole. Such as this example below which will return true if both ($a == 3 and $b == 4) are true and $c == 5 is -also true. - -{% highlight php %} -<?php -return ($a == 3 && $b == 4) && $c == 5; -{% endhighlight %} - -Another example is the snippet below which will return true if ($a != 3 AND $b != 4) OR $c == 5. - -{% highlight php %} -<?php -return ($a != 3 && $b != 4) || $c == 5; -{% endhighlight %} - -* [Ternary operators](http://php.net/language.operators.comparison) - -## Variable declarations - -At times, coders attempt to make their code "cleaner" by declaring predefined variables with a different name. What -this does in reality is to double the memory consumption of said script. For the example below, let us say an example -string of text contains 1MB worth of data, by copying the variable you've increased the scripts execution to 2MB. - -{% highlight php %} -<?php -$about = 'A very long string of text'; // uses 2MB memory -echo $about; - -// vs - -echo 'A very long string of text'; // uses 1MB memory -{% endhighlight %} - -* [Performance tips](http://web.archive.org/web/20140625191431/https://developers.google.com/speed/articles/optimizing-php) diff --git a/pages/example.md b/pages/example.md deleted file mode 100644 index 81e01eb..0000000 --- a/pages/example.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -layout: page -title: Example Stand-Alone Page ---- - -# Page Title - -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod -tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, -quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo -consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse -cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non -proident, sunt in culpa qui officia deserunt mollit anim id est laborum. - -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod -tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, -quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo -consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse -cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non -proident, sunt in culpa qui officia deserunt mollit anim id est laborum. - -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod -tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, -quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo -consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse -cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non -proident, sunt in culpa qui officia deserunt mollit anim id est laborum. diff --git a/scripts/setup.js b/scripts/setup.js index 84ac55b..07cf292 100644 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -17,6 +17,7 @@ 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('')); } + $ul.append('<li><a href="https://github.com/alexeymezenin/laravel-best-practices" target="_blank">Laravel best practices - alexeymezenin</a>(approved by author)</li>'); $contributors.html($ul); } else { fail(); diff --git a/server-architecture.md b/server-architecture.md new file mode 100644 index 0000000..afa12d1 --- /dev/null +++ b/server-architecture.md @@ -0,0 +1,8 @@ +--- +layout: page +title: Server Architecture +description: "production-grade server network design for your Laravel application" +sitemap: true +--- + +<img src="../images/Laravel-Servers-Architecture.jpg" alt="Server Network Design" style="width: 700px;"/> \ No newline at end of file diff --git a/styles/all.css b/styles/all.css index d5d9d63..3bf5c3d 100644 --- a/styles/all.css +++ b/styles/all.css @@ -3111,6 +3111,11 @@ select { } .site-content { padding: 20px 40px 40px 320px; + font-family: sans-serif; + max-width: 800px; + margin: 0 auto; + font-size: 125%; + line-height: 135%; } .site-content h1 { clear: both; diff --git a/styles/print.css b/styles/print.css index e9b865a..10ed59e 100644 --- a/styles/print.css +++ b/styles/print.css @@ -9,4 +9,8 @@ nav.site-navigation, a.fork-me, a.top{ div.site-content{ padding: 20px 40px 40px 20px; +} + +td{ + padding:5px; } \ No newline at end of file diff --git a/styles/site/site-content.less b/styles/site/site-content.less index 23d556d..432380c 100644 --- a/styles/site/site-content.less +++ b/styles/site/site-content.less @@ -1,6 +1,10 @@ .site-content{ padding: 20px 40px 40px 320px; - + font-family: sans-serif; + max-width: 800px; + margin: 0 auto; + font-size: 125%; + line-height: 135%; h1{ clear: both; } @@ -18,3 +22,4 @@ font-size: 12px; text-decoration: none !important; } +