<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Laravel Archives : vedmant.com : coding blog</title>
	<atom:link href="https://vedmant.com/tag/laravel/feed/" rel="self" type="application/rss+xml" />
	<link>https://vedmant.com/tag/laravel/</link>
	<description>Sharing my personal experience in web development</description>
	<lastBuildDate>Tue, 23 Apr 2019 13:54:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>
	<item>
		<title>Laravel Shortcodes</title>
		<link>https://vedmant.com/laravel-shortcodes/</link>
					<comments>https://vedmant.com/laravel-shortcodes/#comments</comments>
		
		<dc:creator><![CDATA[vedmant]]></dc:creator>
		<pubDate>Tue, 23 Apr 2019 13:41:41 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[My Projects]]></category>
		<category><![CDATA[Composer]]></category>
		<category><![CDATA[Package]]></category>
		<category><![CDATA[Shortcodes]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://vedmant.com/?p=241</guid>

					<description><![CDATA[<p>WordPress based Shortcodes for Laravel 5.x with shared variables, debugbar integration, flexible configuration and other useful features. Github: https://github.com/vedmant/laravel-shortcodes﻿ Build powerful and simple layouts using shortcodes in the content or views like this: Installation Via Composer This package supports Laravel Auto-Discover and will be discovered automatically. For Laravel version before 5.5 please add the Vedmant\LaravelShortcodes\LaravelShortcodesServiceProvider::class &#8230; <a href="https://vedmant.com/laravel-shortcodes/" class="more-link">Continue reading <span class="screen-reader-text">Laravel Shortcodes</span></a></p>
<p>The post <a href="https://vedmant.com/laravel-shortcodes/">Laravel Shortcodes</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>WordPress based Shortcodes for Laravel 5.x with shared variables, debugbar integration, flexible configuration and other useful features.</p>



<p>Github: <a href="https://github.com/vedmant/laravel-shortcodes" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">https://github.com/vedmant/laravel-shortcodes﻿</a></p>



<p>Build powerful and simple layouts using shortcodes in the content or views like this:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&#x5B;b]Bold text&#x5B;/b]
&#x5B;row]
  &#x5B;col md=8]
     &#x5B;posts_list types="post,gallery" show_tags="yes"]
  &#x5B;/col]
  &#x5B;col md=4]
     &#x5B;poll id="1"]
     &#x5B;user_info username="test_user" website="mywebsite.com" active="yes"]
     &#x5B;last_free_post title="Free Posts"]
  &#x5B;/col]
&#x5B;/row]
</pre></div>


<h2 class="wp-block-heading"><a href="https://github.com/vedmant/laravel-shortcodes#installation"></a>Installation</h2>



<p>Via Composer</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
$ composer require vedmant/laravel-shortcodes
</pre></div>


<p>This package supports Laravel Auto-Discover and will be discovered automatically.</p>



<p>For Laravel version before 5.5 please add the Vedmant\LaravelShortcodes\LaravelShortcodesServiceProvider::class to the providers array in&nbsp;<code>config/app.php</code>. And optionally &#8216;Shortcodes&#8217; =&gt; Vedmant\LaravelShortcodes\Facades\Shortcodes::class, to aliases.</p>



<h2 class="wp-block-heading"><a href="https://github.com/vedmant/laravel-shortcodes#configuraton"></a>Configuraton</h2>



<p>Publish configuration.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
php artisan vendor:publish --tag=shortcodes
</pre></div>


<h2 class="wp-block-heading"><a href="https://github.com/vedmant/laravel-shortcodes#usage"></a>Usage</h2>



<h3 class="wp-block-heading"><a href="https://github.com/vedmant/laravel-shortcodes#shortcode-class"></a>Shortcode class</h3>



<p>Shortcode class should extend abstract \Vedmant\LaravelShortcodes\Shortcode class.</p>



<p>This packages adds&nbsp;<code>make:shortcode</code>&nbsp;artisan command:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
php artisan make:shortcode PostsListShortcode
</pre></div>


<p>It will generate a shortcode class in the&nbsp;<code>app/Shortcodes</code>&nbsp;folder by default.</p>



<h3 class="wp-block-heading"><a href="https://github.com/vedmant/laravel-shortcodes#register-shortcodes"></a>Register shortcodes</h3>



<p>You can use AppServiceProvider boot method to register all needed shortcodes.</p>



<p>Using shortcode class:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
Shortcodes::add('b', BShortcode::class);
</pre></div>


<p>Using shortcode classes in array, preferable for lots of shortcodes:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
Shortcodes::add(&#x5B;
   &#039;a&#039; =&gt; AShortcode::class,
   &#039;b&#039; =&gt; BShortcode::class,
]);
</pre></div>


<p>Using closure:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
Shortcodes::add(&#039;test&#039;, function ($atts, $content, $tag, $manager) {
   return new HtmlString(&#039;&lt;strong&gt;some test shortcode&lt;/strong&gt;&#039;);
});

</pre></div>


<h3 class="wp-block-heading"><a href="https://github.com/vedmant/laravel-shortcodes#rendering-shortcodes"></a>Rendering shortcodes</h3>



<p>By default this packages extends View to parse all shortcodes during views rendering. This feature can be disabled in the config file.</p>



<p>Also to enable / disable rendering shortcodes for specific view you can use:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
view(&#039;some-view&#039;)-&gt;withShortcodes(); // Or view(&#039;some-view&#039;)-&gt;withoutShortcodes();
</pre></div>


<p>To render shortcodes manually use:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
{{ Shortcodes::render('&#x5B;b]bold&#x5B;/b]') }}
</pre></div>


<h3 class="wp-block-heading"><a href="https://github.com/vedmant/laravel-shortcodes#shared-attributes"></a>Shared attributes</h3>



<p>YOccasionally, you may need to share a piece of data with all shortcodes that are rendered by your application. You may do so using the shortode facade&#8217;s&nbsp;<code>share</code>&nbsp;method. Typically, you should place calls to share in the controller, or within a service provider&#8217;s boot method.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
Shortcodes::share('post', $post);
</pre></div>


<p>Then you can get share attributes in the shortcode class:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
$post = $this-&gt;shared(&#039;post&#039;); $allShared = $this-&gt;shared();
</pre></div>


<h3 class="wp-block-heading"><a href="https://github.com/vedmant/laravel-shortcodes#comma-separated-values-array-attributes"></a>Comma separated values (array attributes)</h3>



<p>If you need to pass an array to a shortcode, you can pass values separated by comma:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#x5B;posts_list ids="1,2,3"]
</pre></div>


<p>Then in render function you can parse this attribute using build in method:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
$ids = $this-&gt;parseCommaSeparated($atts&#x5B;&#039;ids&#039;]);
</pre></div>


<p>Edit configuration file as needed.</p>



<h3 class="wp-block-heading"><a href="https://github.com/vedmant/laravel-shortcodes#integration-with-laravel-debugbar"></a>Integration with Laravel Debugbar</h3>



<p>This packages supports Laravel Debugbar. Integration can be disabled in the config file if needed.<br></p>



<p>This project is fully free to use for any purpose and licensed under MIT License.</p>
<p>The post <a href="https://vedmant.com/laravel-shortcodes/">Laravel Shortcodes</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://vedmant.com/laravel-shortcodes/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Sample Single Page Application (SPA) using Laravel 5 &#038; Vue2 + Vuex + Vue-Router</title>
		<link>https://vedmant.com/sample-single-page-application-spa-using-laravel-5-vue2-vuex-vue-router/</link>
					<comments>https://vedmant.com/sample-single-page-application-spa-using-laravel-5-vue2-vuex-vue-router/#comments</comments>
		
		<dc:creator><![CDATA[vedmant]]></dc:creator>
		<pubDate>Sat, 19 Aug 2017 18:04:16 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Laravel]]></category>
		<category><![CDATA[My Projects]]></category>
		<category><![CDATA[Vue.js]]></category>
		<category><![CDATA[E2E tests]]></category>
		<category><![CDATA[phpunit]]></category>
		<category><![CDATA[REST API]]></category>
		<category><![CDATA[SPA]]></category>
		<category><![CDATA[vue-router]]></category>
		<category><![CDATA[Vuex]]></category>
		<guid isPermaLink="false">https://vedmant.com/?p=180</guid>

					<description><![CDATA[<p>Not to long ago I implemented a sample Single Page Application using Laravel 5 and Vue2 + Vuex + Vue-Router. Today I decided to make it public and share my experience with others. The project is basically a simple Running Tracker, where you can add your running entries and see your performance during some period &#8230; <a href="https://vedmant.com/sample-single-page-application-spa-using-laravel-5-vue2-vuex-vue-router/" class="more-link">Continue reading <span class="screen-reader-text">Sample Single Page Application (SPA) using Laravel 5 &#038; Vue2 + Vuex + Vue-Router</span></a></p>
<p>The post <a href="https://vedmant.com/sample-single-page-application-spa-using-laravel-5-vue2-vuex-vue-router/">Sample Single Page Application (SPA) using Laravel 5 &#038; Vue2 + Vuex + Vue-Router</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Not to long ago I implemented a sample Single Page Application using Laravel 5 and Vue2 + Vuex + Vue-Router.</p>
<p>Today I decided to make it public and share my experience with others.</p>
<p>The project is basically a simple Running Tracker, where you can add your running entries and see your performance during some period of time.</p>
<h3>Main features</h3>
<ul>
<li>Fully separate Backend and Frontend</li>
<li>Authentication based on Laravel Passport</li>
<li>List pages with filters and CRUD editing</li>
<li>Admin panel</li>
<li>Simple widgets</li>
<li>Simple reports</li>
<li>Full Phpunit test coverage</li>
<li>Sample E2E tests using Nightwatch and Cypress</li>
</ul>
<h3>Includes</h3>
<ul>
<li><a href="https://laravel.com/docs/5.4/passport">Laravel Passport</a> API Authentication</li>
<li><a href="https://github.com/mpociot/laravel-apidoc-generator">API Docs Gerator</a> Laravel API Documentation Generator</li>
<li><a href="https://github.com/barryvdh/laravel-debugbar">Laravel DebugBar</a> Debug bar for Laravel</li>
<li><a href="https://vuejs.org/">Vue.js</a> The Progressive JavaScript Framework</li>
<li><a href="https://vuex.vuejs.org/en/intro.html">Vuex</a> State management pattern + library for Vue.js</li>
<li><a href="https://router.vuejs.org/en/">Vue-Router</a> Router library for Vue.js</li>
</ul>
<h3>Other Features</h3>
<ul>
<li>Front page</li>
<li>Authentication (registration, login, logout, throttle)</li>
<li>Users roles: administrator (all access), manager (manage records)</li>
<li>User dashborad with widgets and charts</li>
<li>Entries list with filter by date (list, show, edit, delete, create)</li>
<li>Report page with chart</li>
<li>User profile page</li>
<li>Admin dashboard with widgets</li>
<li>Users admin (list, show, edit, delete, create)</li>
<li>Entries admin (list, show, edit, delete, create)</li>
<li>Global loader for all requests with small delay</li>
</ul>
<p><div class="carousel-slider-outer carousel-slider-outer-image-carousel carousel-slider-outer-191" style="--carousel-slider-nav-color:#f1f1f1;--carousel-slider-active-nav-color:#4caf50;--carousel-slider-arrow-size:48px;--carousel-slider-bullet-size:10px">
<div id="&#039;id-191" class="carousel-slider carousel-slider-191 arrows-visibility-always dots-visibility-never arrows-outside dots-center dots-circle owl-carousel" data-slide-type="image-carousel" data-owl-settings='{"nav":true,"dots":false,"slideBy":1,"stagePadding":0,"margin":10,"loop":true,"lazyLoad":true,"autoplay":true,"autoplayTimeout":10000,"autoplaySpeed":500,"autoplayHoverPause":true,"autoWidth":false,"responsive":{"300":{"items":1},"576":{"items":1},"768":{"items":1},"1024":{"items":1},"1280":{"items":1},"1536":{"items":1}}}'>
<div class="carousel-slider__item">
	<img class="owl-lazy" data-src="https://vedmant.com/wp-content/uploads/2017/08/2017-08-19_1712.jpg" alt=""></a></div>

<div class="carousel-slider__item">
	<img class="owl-lazy" data-src="https://vedmant.com/wp-content/uploads/2017/08/2017-08-19_1713.jpg" alt=""></a></div>

<div class="carousel-slider__item">
	<img class="owl-lazy" data-src="https://vedmant.com/wp-content/uploads/2017/08/2017-08-19_1713.png" alt=""></a></div>

<div class="carousel-slider__item">
	<img class="owl-lazy" data-src="https://vedmant.com/wp-content/uploads/2017/08/2017-08-19_1714.jpg" alt=""></a></div>

</div><!-- .carousel-slider-191 -->
</div><!-- .carousel-slider-outer-191 -->
</p>
<p></p>
<p><a href="https://github.com/vedmant/running-time">GitHub Link</a></p>
<p><a href="https://running-time.vedmant.com/">Demo</a></p>
<p>Use login: <code>user@gmail.com</code> and password: <code>123456</code></p>
<p>This project is fully free to use for any purpose and licenced under MIT License.</p>
<p>The post <a href="https://vedmant.com/sample-single-page-application-spa-using-laravel-5-vue2-vuex-vue-router/">Sample Single Page Application (SPA) using Laravel 5 &#038; Vue2 + Vuex + Vue-Router</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://vedmant.com/sample-single-page-application-spa-using-laravel-5-vue2-vuex-vue-router/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Testing emails with Laravel</title>
		<link>https://vedmant.com/testing-emails-laravel/</link>
					<comments>https://vedmant.com/testing-emails-laravel/#respond</comments>
		
		<dc:creator><![CDATA[vedmant]]></dc:creator>
		<pubDate>Thu, 18 May 2017 12:32:34 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Emails]]></category>
		<guid isPermaLink="false">https://vedmant.com/?p=172</guid>

					<description><![CDATA[<p>Reliability of emails subsystem is essential for current web applications, but testing emails is not as easy at it looks at first glance. Laravel doesn&#8217;t provide a good solution for testing emails out of the box, so after a bit of Googling I come up with following solution for testing emails. Helper Basic idea is &#8230; <a href="https://vedmant.com/testing-emails-laravel/" class="more-link">Continue reading <span class="screen-reader-text">Testing emails with Laravel</span></a></p>
<p>The post <a href="https://vedmant.com/testing-emails-laravel/">Testing emails with Laravel</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Reliability of emails subsystem is essential for current web applications, but testing emails is not as easy at it looks at first glance. Laravel doesn&#8217;t provide a good solution for testing emails out of the box, so after a bit of Googling I come up with following solution for testing emails.</p>
<h3>Helper</h3>
<p>Basic idea is build on attaching event listener to Swift emails package, for this I extended base class <code>Swift_Events_EventListener</code> that takes as parameter our test case.</p>
<pre class="brush: php; title: ; notranslate">
/**
 * Class TestingMailEventListener
 *
 * @package Tests
 */
class TestingMailEventListener implements Swift_Events_EventListener
{
    protected $test;

    /**
     * TestingMailEventListener constructor.
     *
     * @param $test
     */
    public function __construct($test)
    {
        $this-&gt;test = $test;
    }

    /**
     * Before email sent
     * 
     * @param Swift_Events_SendEvent $event
     */
    public function beforeSendPerformed(Swift_Events_SendEvent $event)
    {
        $this-&gt;test-&gt;addEmail($event-&gt;getMessage());
    }
}
</pre>
<p>Then I created a Trait with following method:</p>
<pre class="brush: php; title: ; notranslate">
/**
 * Trait TracksEmails
 *
 * @package Tests
 */
trait TracksEmails
{
    /**
     * Delivered emails.
     * @var array
     */
    protected $emails = &#x5B;];

    /**
     * Register a listener for new emails.
     *
     * @before
     */
    public function setUpMailTracking()
    {
        Mail::getSwiftMailer()
            -&gt;registerPlugin(new TestingMailEventListener($this));
    }
...
</pre>
<p>Which registers event listener and collects all emails sent with Swift.</p>
<p>Having this done it&#8217;s easy to check whether particular email was sent, I also added bunch of helpers to make it easier:</p>
<pre class="brush: php; title: ; notranslate">
/**
 * Assert that at least one email was sent.
 * @return $this
 */
protected function seeEmailWasSent()

/**
 * Assert that the given number of emails were sent.
 *
 * @param integer $count
 * @return $this
 */
protected function seeEmailsSent($count)

/**
 * Assert that the last email's body contains the given text.
 *
 * @param string $excerpt
 * @param Swift_Mime_Message $message
 * @return $this
 */
protected function seeEmailContains($excerpt, Swift_Mime_Message $message = null)
...
</pre>
<p>And several more.</p>
<p>Here you can see full helper trait code <a href="https://gist.github.com/vedmant/57a908908457e160f5cab39cc7a93d5b"  target="_blank">click</a>.</p>
<h3>Usage</h3>
<p>Usage of this helper is quite simple, here is simple example:</p>
<pre class="brush: php; title: ; notranslate">
public function testEmail()
{
    \Mail::raw('Some content', function (Message $message) {
        $message-&gt;from('laravel@test.com', 'Laravel');
        $message-&gt;to('testmail@test.com');
    });

    $this-&gt;seeEmailWasSent()
        -&gt;seeEmailTo('testmail@test.com')
        -&gt;seeEmailContains('Some content');
}
</pre>
<p>And a bit more complex example of how I test my password reset form:</p>
<pre class="brush: php; title: ; notranslate">
public function testPasswordReset()
{
    $user = $this-&gt;makeUser();

    Event::listen(NotificationSent::class, function (NotificationSent $notification) use ($user) {
        self::$token = $notification-&gt;notification-&gt;token;
        $this-&gt;seeEmailWasSent()
            -&gt;seeEmailTo($user-&gt;Login)
            -&gt;seeEmailContains(self::$token);
    });

    $this-&gt;visitRoute('password.request')
        -&gt;assertResponseOk()
        -&gt;type($user-&gt;Login, 'email')
        -&gt;press('Reset')
        -&gt;assertResponseOk()
        -&gt;see(trans('passwords.sent'))
        -&gt;seeInDatabase('password_resets', &#x5B;'email' =&gt; $user-&gt;Login]);

    $this-&gt;visitRoute('password.reset', &#x5B;'token' =&gt; self::$token])
        -&gt;assertResponseOk()
        -&gt;type($user-&gt;Login, 'email')
        -&gt;type('123123', 'password')
        -&gt;type('123123', 'password_confirmation')
        -&gt;press('Reset Password')
        -&gt;assertResponseOk()
        -&gt;seeRouteIs('dashboard');

    $this-&gt;assertTrue($this-&gt;isAuthenticated());

    $this-&gt;assertTrue(app('hash')-&gt;check('123123', $user-&gt;fresh()-&gt;Password));
}
</pre>
<p>In this example I used events listener to listen for notification to check if sent token is the correct one.</p>
<p>Currently there are some probably better alternatives for testing emails with Laravel, like this one <a href="https://github.com/tightenco/mailthief" target="_blank">tightenco/mailthief</a>.</p>
<p>The post <a href="https://vedmant.com/testing-emails-laravel/">Testing emails with Laravel</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://vedmant.com/testing-emails-laravel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>MS SQL on Vagrant Ubuntu Homestead box for development on Laravel</title>
		<link>https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/</link>
					<comments>https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/#comments</comments>
		
		<dc:creator><![CDATA[vedmant]]></dc:creator>
		<pubDate>Thu, 02 Feb 2017 12:57:43 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[MSSql]]></category>
		<category><![CDATA[SqlSrv]]></category>
		<guid isPermaLink="false">https://vedmant.com/?p=135</guid>

					<description><![CDATA[<p>Hi everyone! Recently I had a chance to setup and successfully run development environment with Microsoft SQL Server on Laravel&#8217;s Homestead Vagrant box. I used Homestead installation per project. And here is how I&#8217;ve done it. Prepare Homestead box First step is to install Homestead for a project: composer require laravel/homestead --dev php vendor/bin/homestead make &#8230; <a href="https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/" class="more-link">Continue reading <span class="screen-reader-text">MS SQL on Vagrant Ubuntu Homestead box for development on Laravel</span></a></p>
<p>The post <a href="https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/">MS SQL on Vagrant Ubuntu Homestead box for development on Laravel</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hi everyone!</p>
<p>Recently I had a chance to setup and successfully run development environment with Microsoft SQL Server on Laravel&#8217;s Homestead Vagrant box. I used Homestead installation per project. And here is how I&#8217;ve done it.</p>
<h3>Prepare Homestead box</h3>
<p>First step is to install Homestead for a project:</p>
<pre class="brush: bash; title: ; notranslate">
composer require laravel/homestead --dev
php vendor/bin/homestead make
</pre>
<p>Then you need to change Homestead.yaml file.</p>
<p>Firstly, memory limit have to be changed to 4096: <code>memory: 4096</code></p>
<p>Then hostname: <code>hostname: mysite.dev</code></p>
<p>And probably name for convenience: &#8216;name: mysite.dev&#8217;</p>
<p>In <code>sites</code> section make sure that you have configuration like this:</p>
<pre class="brush: yaml; title: ; notranslate">
sites:
    - map: mysite.dev
      to: &quot;/home/vagrant/project/public&quot;
</pre>
<p>Then download and install Vagrant box</p>
<pre class="brush: plain; title: ; notranslate">
vagrant up
</pre>
<p>And add to hosts file domain for a this box <code>192.168.10.10 mysite.dev</code>.</p>
<h3>Install, setup and import database</h3>
<p>To setup database login to Vagrant box</p>
<pre class="brush: bash; title: ; notranslate">
vagrant ssh
</pre>
<p>Install MS SQL server and tools:</p>
<pre class="brush: bash; title: ; notranslate">
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

sudo apt-get update
sudo apt-get install -y mssql-server
sudo apt-get install -y mssql-tools unixodbc-dev

sudo ln -sfn /opt/mssql-tools/bin/sqlcmd-13.0.1.0 /usr/bin/sqlcmd
sudo ln -sfn /opt/mssql-tools/bin/bcp-13.0.1.0 /usr/bin/bcp
</pre>
<p>Then run initial MS SQL setup script</p>
<pre class="brush: bash; title: ; notranslate">
sudo /opt/mssql/bin/mssql-conf setup
</pre>
<p>Use password &#8220;Secret123&#8221;, start server and enable starting on boot</p>
<p>Then it will require to install Sybase php extension</p>
<pre class="brush: bash; title: ; notranslate">
sudo apt-get install -y php7.1-sybase
</pre>
<p>When it will be updating some packages, select to keep the local version of config files on prompts.</p>
<p>To connect your Laravel application to MS SQL server you may need to add following configuration to your <code>config/database.php</code> file to <code>connections</code> section:</p>
<pre class="brush: php; title: ; notranslate">
'sqlsrv' =&gt; &#x5B;
    'driver' =&gt; 'sqlsrv',
    'host' =&gt; env('DB_HOST', 'localhost'),
    'database' =&gt; env('DB_DATABASE', 'forge'),
    'username' =&gt; env('DB_USERNAME', 'sa'),
    'password' =&gt; env('DB_PASSWORD', ''),
    'charset' =&gt; 'utf8',
    'prefix' =&gt; '',
],
</pre>
<p>After this application should be able to successfully connect to MS Sql server.</p>
<p>To import database, copy database *.BAK files to project folder, open sqlcmd console</p>
<pre class="brush: bash; title: ; notranslate">
sqlcmd -U sa -P 'Secret123'
</pre>
<p>and run following queries to import MYDB.BAK database backup file</p>
<pre class="brush: sql; title: ; notranslate">
RESTORE DATABASE &#x5B;mydb] FROM DISK='/home/vagrant/project/MYDB.BAK'
WITH  FILE = 1,  
MOVE N'MYDB_dat' TO N'/var/opt/mssql/data/mydb.mdf',
MOVE N'MYDB_log' TO N'/var/opt/mssql/data/mydb.ldf',
NOUNLOAD,  REPLACE,  STATS = 1
GO
</pre>
<p>That&#8217;s basically all to install and run MS SQL on your Homestead Vagrant box, if you have any questions, feel free to contact!</p>
<p>The post <a href="https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/">MS SQL on Vagrant Ubuntu Homestead box for development on Laravel</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
	</channel>
</rss>
