{"id":11202,"date":"2018-01-05T11:03:27","date_gmt":"2018-01-05T05:33:27","guid":{"rendered":"https:\/\/www.carmatec.com\/?p=11202"},"modified":"2022-09-06T07:16:23","modified_gmt":"2022-09-06T07:16:23","slug":"laravel-5-5-updates-means-developers","status":"publish","type":"post","link":"https:\/\/stage.carmatec.com\/nl\/php-ontwikkeling\/laravel-5-5-updates-means-developers\/","title":{"rendered":"Laravel 5.5 Updates And What It Means For The Developers"},"content":{"rendered":"<p>Laravel 5.5, released on 30th August 2017, is the current stable version of the popular open-source <a href=\"https:\/\/stage.carmatec.com\/nl\/technologie-leren\/top-php-frameworks-voor-agile-applicatieontwikkeling\/\">PHP web framework<\/a>. It requires PHP 7.0+, which includes speed improvements that will decrease the CPU load by about half, along with developer features for operation. The 5.5 version offers bug fixes for 2 years and security updates for 3 years making it the much-needed LTS (Long Term Support) release since the two-year window of Laravel 5.1 bug fix benefits has come to an end.<\/p>\n<p>The major updates of this version are as follows:<\/p>\n<h4><\/h4>\n<h2><strong>1. Introduces The <em>migrate:fresh<\/em> Command<\/strong><\/h2>\n<p>The new <strong>php artisan<\/strong> <strong>migrate:fresh<\/strong> command works similar to the <strong>migrate:refresh<\/strong> command. However, while migrate:refresh rolls back all the migrations, <strong>migrate:fresh<\/strong> drops all tables and run the existing migrations from scratch. This new command is most useful when working with foreign key constraints or when you have a <strong>down()<\/strong> method in the migration that has not been well defined.<\/p>\n<h4><\/h4>\n<h2><strong>2. Introduces Three Front-end Presets<\/strong><\/h2>\n<ul>\n<li>Bootstrap<\/li>\n<li>Vue<\/li>\n<li>Reageer op<\/li>\n<\/ul>\n<p>By default, the preset is set at Vue and can be changed to React or Bootstrap.<br \/>\nWe can change the preset to react using the command <strong>php artisan preset react<\/strong>. Or if you don\u2019t want to work with any of the front-end scaffolding, use the command <strong>php artisan preset none<\/strong>.<\/p>\n<h4><\/h4>\n<h2><strong>3. Enables Automatic Package Discovery<\/strong><\/h2>\n<p>Up until now, using a third-party package in Laravel projects meant having to instal the package, register its service providers and add the aliases through the package&#8217;s <strong>composer.json<\/strong> file. Laravel 5.5 makes the process much simpler with its automatic package discovery feature. If the package has been configured for auto discovery, you will be able to use in on the fly! Similarly, when you uninstall a package, the auto discovery feature will remove the service providers and facades in the <strong>config\/app.php<\/strong> bestand.<\/p>\n<h4><\/h4>\n<h2><strong>4. A Streamlined Request Validation Process<\/strong><\/h2>\n<p>Laravel 5.5 has made two major changes to the request feature.<br \/>\n1. You can directly create objects from the validated data\u2013you no longer need controlled validator but can instead call the validator on your <strong>Request<\/strong> instance.<br \/>\n2. You can store the data returned by the validator in a variable and pass on to the <strong>create<\/strong> method of the model.<\/p>\n<h4><\/h4>\n<h2><strong>5. Whoops Makes A Return!<\/strong><\/h2>\n<p>The return of Whoops! simplifies the error debugging process to a large extent. It not only points out the exact line of the code which caused the error and marks a stack trace to the error with a screenshot, but also allows direct access to the reference files in the editor or IDE\u2013the PHP-source files should be locally accessible for this feature. You also have quick access to all the set environmental variables and icons that allow error search through Google, <a href=\"https:\/\/stackoverflow.com\/\">StackOverflow<\/a> of <a href=\"https:\/\/duckduckgo.com\/\">DuckDuckGo<\/a>.<\/p>\n<h4><\/h4>\n<h2><strong>6. Simpler Custom Validation Rules<\/strong><\/h2>\n<p>Laravel 5.5 has refined and simplified the creation of custom validation rule with a new artisan command, <strong>$ php artisan make:rule FooBarRule<\/strong>. This command creates a new FooBarRule class in the .\/app\/Rules directory and extends a Rule contract which compels it to apply the passes and message methods. This gives the scope to define the validator logic and error message.<\/p>\n<h4><\/h4>\n<h2><strong>7. New Exception Helper Functions<\/strong><\/h2>\n<p>Laravel 5.5 allows you to write more expressive code with its two exception helper functions: <strong>throw_if<\/strong> en <strong>throw_unless<\/strong> methods. Both helpers work exactly as their name suggests and may help us to reduce a conditional block to a single line when you want to throw an exception based on a condition.<\/p>\n<p><strong>throw_if<\/strong> throws the exception if the boolean is positive.<br \/>\n<strong>throw_unless<\/strong> throws the exception when the boolean is negative.<\/p>\n<p>Both helpers take three arguments, with the third being optional. First one is a boolean, second is the exception class and third is the exception message passed in case you didn&#8217;t pass with the instantiation of the exception in the second argument.<\/p>\n<h4><\/h4>\n<h2><strong>8. Supports Customised Email Layouts &amp; Themes<\/strong><\/h2>\n<p>Laravel 5.5 allows you to use custom email themes for mailables. You simply need to create a custom <strong>.css<\/strong> file that specifies the style requirement. This simple feature lets you tweak the email layout to your requirements and can be very impactful with respect to branding.<\/p>\n<h4><\/h4>\n<h2><strong>9. Renders Mailables to the Browser<\/strong><\/h2>\n<p>Laravel 5.5 allows you to directly render email layouts to the browser giving you the tool to make instant changes. It displays email templates directly from our routes thus making testing of email templates quicker and easier.<\/p>\n<p>To create a mailable, use<br \/>\n<strong>php artisan make:mail UserWelcome&#8211;markdown=emails.user.subscription.canceled<\/strong><br \/>\nAnd then render it through a route<br \/>\n<strong>Route::get(&#8216;\/no\/way&#8217;, function () {<\/strong><br \/>\n<strong> return new App\\Mail\\UserSubscriptionCanceled();<\/strong><br \/>\n<strong> });<\/strong><\/p>\n<h4><\/h4>\n<h2><strong>10. The <em>vendor:publish<\/em> Command Is More Specific<\/strong><\/h2>\n<p>In Laravel 5.5, when you run a <strong>php artisan vendor:publish command<\/strong>, you will be prompted to choose a tag or provider, making it easier to publish only what you want. You can choose to bypass this feature by using the <strong>&#8211;all<\/strong> of <strong>&#8211;provider flag<\/strong><\/p>\n<p>Als toonaangevend <a href=\"https:\/\/stage.carmatec.com\/nl\/ontwikkelbedrijf-voor-mobiele-apps\/\">PHP ontwikkelingsbedrijf<\/a>, <strong><a href=\"https:\/\/stage.carmatec.com\/nl\/\">Carmatec<\/a><\/strong> stays on top of all technological advances and applies them to deliver creative solutions for business challenges and requirements. <a href=\"https:\/\/stage.carmatec.com\/nl\/contact-met-ons-opnemen\/\">Get in touch with us today<\/a> to boost your company\u2019s online presence.<\/p>\n<div id=\"s3gt_translate_tooltip_mini\" class=\"s3gt_translate_tooltip_mini_box\" style=\"background: initial ! important; border: initial ! important; border-radius: initial ! important; border-spacing: initial ! important; border-collapse: initial ! important; direction: ltr ! important; flex-direction: initial ! important; font-weight: initial ! important; height: initial ! important; letter-spacing: initial ! important; min-width: initial ! important; max-width: initial ! important; min-height: initial ! important; max-height: initial ! important; margin: auto ! important; outline: initial ! important; padding: initial ! important; position: absolute; table-layout: initial ! important; text-align: initial ! important; text-shadow: initial ! important; width: initial ! important; word-break: initial ! important; word-spacing: initial ! important; overflow-wrap: initial ! important; box-sizing: initial ! important; display: initial ! important; color: inherit ! important; font-size: 13px ! important; font-family: X-LocaleSpecific,sans-serif,Tahoma,Helvetica ! important; line-height: 13px ! important; vertical-align: top ! important; white-space: inherit ! important; left: 296px; top: 2428px; opacity: 0.05;\">\n<div id=\"s3gt_translate_tooltip_mini_logo\" class=\"s3gt_translate_tooltip_mini\" title=\"Vertaal geselecteerde tekst\"><\/div>\n<div id=\"s3gt_translate_tooltip_mini_sound\" class=\"s3gt_translate_tooltip_mini\" title=\"Speel\"><\/div>\n<div id=\"s3gt_translate_tooltip_mini_copy\" class=\"s3gt_translate_tooltip_mini\" title=\"Tekst kopi\u00ebren naar klembord\"><\/div>\n<\/div>\n<h3><\/h3>","protected":false},"excerpt":{"rendered":"<p>Laravel 5.5, released on 30th August 2017, is the current stable version of the popular open-source PHP web framework. It requires PHP 7.0+, which includes speed improvements that will decrease the CPU load by about half, along with developer features for operation. The 5.5 version offers bug fixes for 2 years and security updates for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":30886,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-11202","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-development"],"_links":{"self":[{"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/posts\/11202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/comments?post=11202"}],"version-history":[{"count":1,"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/posts\/11202\/revisions"}],"predecessor-version":[{"id":30469,"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/posts\/11202\/revisions\/30469"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/media\/30886"}],"wp:attachment":[{"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/media?parent=11202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/categories?post=11202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stage.carmatec.com\/nl\/wp-json\/wp\/v2\/tags?post=11202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}