{"id":44512,"date":"2017-01-03T11:12:58","date_gmt":"2017-01-03T05:42:58","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=44512"},"modified":"2017-01-03T14:21:17","modified_gmt":"2017-01-03T08:51:17","slug":"is-your-drupal-8-ready-for-writing-codes","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/is-your-drupal-8-ready-for-writing-codes\/","title":{"rendered":"Is your Drupal 8 Ready for Writing Codes?"},"content":{"rendered":"<p>Are you excited to write your own code in <a title=\"Advantages of Drupal 8 over Other CMS\" href=\"http:\/\/www.tothenew.com\/blog\/advantages-of-drupal-8-over-other-cms\/\">Drupal 8<\/a>?<\/p>\n<p>But wait a second,\u00a0<a title=\"Drupal Development\" href=\"http:\/\/www.tothenew.com\/wcm\/drupal-development-consulting-services\">Drupal<\/a>&#8216;s cache may kill all your development hours. This blog is for you, if you are facing any of the following challenges.<\/p>\n<ol>\n<li>Are you struggling to see your changes on web pages?<\/li>\n<li>Every time, you change a piece of code, it doesn&#8217;t reflect until you clear cache.<\/li>\n<li>This problem may get worse, if you have more than 1 GB of database.<\/li>\n<li>You type <strong>drush cr<\/strong> and it takes more than 15-30 minute<\/li>\n<\/ol>\n<p>You must be wondering how to switch off cache in your local development environment?<\/p>\n<p>So, here&#8217;s the blog that will provide you a best way to improve productivity while writing code for <a title=\"10 key features to be excited about Drupal 8\" href=\"http:\/\/www.tothenew.com\/blog\/infographics-10-key-features-to-be-excited-about-in-drupal-8\/\">Drupal 8<\/a>.<\/p>\n<ol>\n<li>Drupal 8 comes with <strong>example.settings.local.php<\/strong> with in <strong>\/sites<\/strong> directory.<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-44513 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/12\/settings_local.png\" alt=\"settings_local\" width=\"758\" height=\"508\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/12\/settings_local.png 758w, \/blog\/wp-ttn-blog\/uploads\/2016\/12\/settings_local-300x201.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/12\/settings_local-624x418.png 624w\" sizes=\"(max-width: 758px) 100vw, 758px\" \/><br \/>\nThis file is built for developers\u00a0and can disable<\/p>\n<ol>\n<li>Caching<\/li>\n<li>JavaScript\/CSS compression<\/li>\n<li>Re-routing of outgoing emails<\/li>\n<\/ol>\n<\/li>\n<li>This file should be copied to <strong>\/sites\/default\/<\/strong> directory.<\/li>\n<li>And this should be renamed into <strong>settings.local.php<\/strong>.<br \/>\nUn-comment following 3 lines in your settings.php. You will get this code around end of your settings.php file. For me it was on line # 753.<\/p>\n<p>[java]# if (file_exists($app_root . &#8216;\/&#8217; . $site_path . &#8216;\/settings.local.php&#8217;)) {<br \/>\n# include $app_root . &#8216;\/&#8217; . $site_path . &#8216;\/settings.local.php&#8217;;<br \/>\n# }[\/java]<\/p>\n<\/li>\n<li>settings.local.php will modify the following in Drupal\n<ol>\n<li>Assertions<\/li>\n<li>Enable local development services. This will include <strong>\/sites\/development.services.yml<\/strong>, which makes life easy for developers.<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-44691\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/12\/development_service.png\" alt=\"development_service\" width=\"747\" height=\"496\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/12\/development_service.png 747w, \/blog\/wp-ttn-blog\/uploads\/2016\/12\/development_service-300x199.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/12\/development_service-624x414.png 624w\" sizes=\"(max-width: 747px) 100vw, 747px\" \/><\/li>\n<li>Show all error messages, with back trace information.<\/li>\n<li>Disable CSS and JS aggregation.<\/li>\n<li>To disable the render cache we need to un-comment\n<p>[java]$settings[&#8216;cache&#8217;][&#8216;bins&#8217;][&#8216;render&#8217;] = &#8216;cache.backend.null&#8217;;[\/java]<\/p>\n<p>In Drupal 8, the rendered data gets cached at multiple levels:<\/p>\n<ol>\n<li>Page<\/li>\n<li>Block<\/li>\n<li>Entity (node, comment, user, etc.)<\/li>\n<li>View<\/li>\n<li>Menu tree<\/li>\n<li>Text Format \ufb01lter result<\/li>\n<\/ol>\n<\/li>\n<li>To disable Dynamic Page Cache\u00a0we need to un-comment\n<p>[java]$settings[&#8216;cache&#8217;][&#8216;bins&#8217;][&#8216;dynamic_page_cache&#8217;] = &#8216;cache.backend.null&#8217;;[\/java]<\/p>\n<\/li>\n<li>Allow test modules and themes to be installed.<\/li>\n<li>Enable access to rebuild.php.<\/li>\n<li>Skip file system permissions hardening.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>Now, the Drupal works normally but without any cache running. If you don&#8217;t face any performance glitch, then you are done. However, in some cases naked Drupal could be very slow.<\/p>\n<p>To improve the performance the developers can add Memcached.<\/p>\n<h2>Memcached<\/h2>\n<p>We have disabled all sort of cache in Drupal. Now, we will add one level of caching by implementing <a href=\"http:\/\/www.tothenew.com\/blog\/aws-memcache-auto-scaling\/\">Memcached <\/a>in the local machine.<\/p>\n<p>I was working on Ubuntu 14.04 so in case you are also on a similar operating system, the \u00a0following steps can help you to implement Memcached in your local environment.<\/p>\n<p>[java]sudo apt-get update<\/p>\n<p>sudo apt-get install php5-memcached memcached<br \/>\n[\/java]<\/p>\n<p>The installation usually is a hassle free task. You can check Memcached is running in the phpinfo().<\/p>\n<p>To restart Memcached, run the following code<\/p>\n<p>[java]sudo service memcached restart[\/java]<\/p>\n<p>Now, enable <a title=\"memcache\" href=\"https:\/\/www.drupal.org\/project\/memcache\" target=\"_blank\">Memcache<\/a> module in Drupal.\u00a0Once enabled, you need to add the following code to the settings.local.php<\/p>\n<pre>$settings['memcache']['servers'] = ['127.0.0.1:11211' =&gt; 'default'];\r\n\r\n$settings['memcache']['bins'] = ['default' =&gt; 'default'];\r\n\r\n$settings['memcache']['key_prefix'] = '';\r\n\r\n$settings['cache']['default'] = 'cache.backend.memcache';\r\n\r\n$settings['cache']['bins']['render'] = 'cache.backend.memcache';\r\n<\/pre>\n<p>Here, we have overridden render cache configuration once again which was disabled earlier in settings.local.php.<\/p>\n<p>We specified &#8216;cache.backend.<strong>memcache<\/strong>&#8216; to use Memcached to render cache data.<\/p>\n<p>So, if you follow this process, you will be set to write a clean code for Drupal 8.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you excited to write your own code in Drupal 8? But wait a second,\u00a0Drupal&#8216;s cache may kill all your development hours. This blog is for you, if you are facing any of the following challenges. Are you struggling to see your changes on web pages? Every time, you change a piece of code, it [&hellip;]<\/p>\n","protected":false},"author":1036,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[3602],"tags":[4862,3601,3604,1370,8],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/44512"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1036"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=44512"}],"version-history":[{"count":1,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/44512\/revisions"}],"predecessor-version":[{"id":53723,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/44512\/revisions\/53723"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=44512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=44512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=44512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}