<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shahjalal on Medium]]></title>
        <description><![CDATA[Stories by Shahjalal on Medium]]></description>
        <link>https://medium.com/@mdjalal2012?source=rss-98fa804cd128------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CxVY_VUvcGRzhFjHQTPzbQ.jpeg</url>
            <title>Stories by Shahjalal on Medium</title>
            <link>https://medium.com/@mdjalal2012?source=rss-98fa804cd128------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:24:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mdjalal2012/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[RuboCop for Rails: Enforcing Clean Code the Smart Way]]></title>
            <link>https://medium.com/@mdjalal2012/rubocop-for-rails-enforcing-clean-code-the-smart-way-e8740c30cd67?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8740c30cd67</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 08:31:40 GMT</pubDate>
            <atom:updated>2025-07-22T08:31:40.551Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lyhw3P37j0hKVgZBB0_tjw.avif" /></figure><p>In this article we will discuss about RuboCop for<strong> clean, readable, and consistent code</strong> is key to long-term project success. For Ruby and Rails developers, <strong>RuboCop</strong> is an indispensable tool that helps enforce code quality and style across our codebase.</p><h3>What is RuboCop?</h3><p><strong>RuboCop</strong> is a <strong>static code analyzer and formatter</strong> for the Ruby programming language. It enforces style guidelines based on the Ruby Style Guide and can automatically correct many violations like syntax error, unused variable or so many rules has in rubocop.</p><p>Here we will discuss about rubocop implementation in ruby on rails porject for checking pre-commit. so, let’s start</p><blockquote><strong>First step: </strong>In this step we install rubocop in out rails project. Add bellow gem in ruby Gemfile in development mode</blockquote><pre>  gem &quot;pre-commit&quot;, require: false<br>  gem &#39;rubocop&#39;, &#39;~&gt; 1.75.0&#39;, require: false<br>  gem &#39;rubocop-rails&#39;, require: false<br>  gem &#39;rubocop-rspec&#39;, require: false<br>  gem &#39;rubocop-performance&#39;, require: false</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OAXDaahQkJ1K5P6k3LbaeA.png" /><figcaption>Sample Gemfile</figcaption></figure><blockquote>Then run <strong>bundle install</strong> in command line in our rails project root directory. the command is</blockquote><pre>bundle install</pre><blockquote><strong>2nd Step</strong>: create new file in this directory config/hooks/pre-commit and add bellow code new create file.</blockquote><pre>#!/bin/sh<br><br># Run RuboCop on staged Ruby files<br>STAGED_RUBY_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep &#39;\.rb$&#39;)<br><br>if [ -n &quot;$STAGED_RUBY_FILES&quot; ]; then<br>  echo &quot;$STAGED_RUBY_FILES&quot; | xargs bundle exec rubocop --force-exclusion<br>else<br>  exit 0<br>fi<br><br><br># Exit with error if RuboCop finds issues<br>if [ $? -ne 0 ]; then<br>  echo &quot;RuboCop found offenses, commit aborted!&quot;<br>  exit 1<br>fi</pre><blockquote><strong>3rd Step</strong>: In this step we create a pre commit yml file in project root directory</blockquote><pre>project/.pre-commit-config.yaml<br><br>repos:<br>- repo: local<br>  hooks:<br>    - id: rubocop<br>      name: rubocop<br>      entry: bundle exec rubocop<br>      language: system<br>      types: [ruby]<br>      stages: [commit]</pre><blockquote><strong>4th Step</strong>: Create a .rubocop.yml if not exist, if exist the update this file using bellow code.</blockquote><pre># .rubocop.yml - Sample RuboCop Configuration<br><br>plugins: <br>  - rubocop-rails <br>  - rubocop-rspec<br>  - rubocop-performance<br><br>AllCops:<br>  # Basic configurations<br>  TargetRubyVersion: 3.2.2<br>  TargetRailsVersion: 7.0.8<br>  NewCops: enable<br>  DisplayCopNames: true<br>  Exclude:<br>    - &#39;bin/**/*&#39;<br>    - &#39;db/**/*&#39;<br>    - &#39;vendor/**/*&#39;<br>    - &#39;node_modules/**/*&#39;<br>    - &#39;spec/fixtures/**/*&#39;<br>    - &#39;tmp/**/*&#39;<br>    - &#39;config/**/*&#39;<br>    - &#39;doc/**/*&#39;<br><br># Layout/LineLength:<br>#   Max: 120<br>#   AllowURI: true<br>#   URISchemes:<br>#     - http<br>#     - https<br><br>Metrics:<br>  Enabled: false<br><br>Style/Documentation:<br>  Enabled: false<br><br>Style/FrozenStringLiteralComment:<br>  Enabled: false<br><br># Rails specific configurations<br>Rails:<br>  Enabled: true<br><br>Rails/FilePath:<br>  EnforcedStyle: slashes<br><br>Rails/OutputSafety:<br>  Enabled: true<br><br># RSpec configurations<br>RSpec/DescribeClass:<br>  Exclude:<br>    - &#39;spec/requests/**/*&#39;<br>    - &#39;spec/system/**/*&#39;<br><br>RSpec/MultipleExpectations:<br>  Max: 4<br><br># Performance configurations<br>Performance/RedundantMerge:<br>  MaxKeyValuePairs: 2<br><br># Custom rule to disable<br>Layout/EndOfLine:<br>  Enabled: false<br><br># Customize indentation<br>Layout/IndentationWidth:<br>  Width: 2<br>Layout/SpaceInsideHashLiteralBraces:<br>  EnforcedStyle: no_space<br><br># Customize hash syntax<br>Style/HashSyntax:<br>  EnforcedStyle: ruby19_no_mixed_keys<br><br># String literals<br>Style/StringLiterals:<br>  EnforcedStyle: single_quotes<br>  ConsistentQuotesInMultiline: true<br><br># Disable check for has_many and has_one dependent<br>Rails/HasManyOrHasOneDependent:<br>  Enabled: false<br><br># Method length<br># Metrics/MethodLength:<br>#   Max: 15<br>#   CountComments: false<br>#   Exclude:<br>#     - &#39;spec/**/*&#39;<br><br># # Block length<br># Metrics/BlockLength:<br>#   Max: 30<br>#   Exclude:<br>#     - &#39;spec/**/*&#39;<br>#     - &#39;config/routes.rb&#39;</pre><p>here we add different type of rule for checking pre-commit. if we want more rule the <a href="https://docs.rubocop.org/rubocop-rails/cops.html"><strong>visit</strong></a></p><blockquote><strong>5th Step</strong>: Now we create command for create rubocop hook setup in project. Create a file in bin/setup-hooks and add bellow code in setup-hooks<br>File location: <em>bin/setup-hooks</em></blockquote><pre>#!/bin/sh<br>cp config/hooks/* .git/hooks/<br>chmod +x .git/hooks/*</pre><blockquote><strong>6th Step</strong>: In this step we create a auto correction setup file when we create a per-commit our code base. This config make correction our code base.</blockquote><p>In same directory(bin) we create a auto-correct-rubocop file and insert bellow code<br>Directory: bin/auto-correct-rubocop</p><pre>#!/bin/sh<br><br># Run RuboCop on staged Ruby files<br>git diff --cached --name-only --diff-filter=ACM | grep &#39;\.rb$&#39; | xargs bundle exec rubocop -a --force-exclusion</pre><p>Finally, we create all types of configure and gem install for rubocop code base pre-commit check. Now we enable rubocop in our project by run bellow command first time only. when we clone this project or new.</p><pre>./bin/setup-hooks</pre><p>Now we are ready to check rubocop precommit in our project directory.</p><p>For checking in application_record.rb we have made some mistake then try to commit but rubocop return the error. the error screenshot is bellow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aRzKgSpQb680Nc4daLir1g.png" /></figure><p>So now we run the auto-correction command for correct the error.it’s has make own correction by this command and result is bellow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXSCvkdorJ0ntTZyBGaXeg.png" /></figure><p>Successfully commit the file with check rubocop pre-commit check.</p><blockquote><strong>Project Repo</strong>: <a href="https://github.com/Shahjalal7311/rubocop"><strong>Repository link</strong></a></blockquote><blockquote>Help Link: <br><a href="https://docs.rubocop.org/rubocop-rails/installation.html">https://docs.rubocop.org/rubocop-rails/installation.html</a><br><a href="https://blog.appsignal.com/2023/09/06/an-introduction-to-rubocop-for-ruby-on-rails.html">https://blog.appsignal.com/2023/09/06/an-introduction-to-rubocop-for-ruby-on-rails.html</a><br>deepseek and Chatgpt also help to configure and implement rubocop.</blockquote><blockquote>This article is based on my personal understanding and experience.<br> I wrote it primarily to help myself in the future, and I hope it can also assist others looking to implement RuboCop in their projects.<br> If you notice any mistakes or typos, feel free to ignore them — or corrections are always welcome and appreciated.</blockquote><h3>Thank you.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8740c30cd67" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel with Inertia.js and React no starter kit]]></title>
            <link>https://medium.com/@mdjalal2012/laravel-with-inertia-js-and-react-no-starter-kit-cb60a157474c?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb60a157474c</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[inertia]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Fri, 27 Dec 2024 03:13:34 GMT</pubDate>
            <atom:updated>2024-12-27T03:13:34.047Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PTGX7iHAf0bIagjn.jpg" /></figure><p>This article we will talk how to setting up a Laravel project with Inertia.js and React on macOS(we can also used <a href="https://laravel.com/docs/11.x/installation#installing-php"><strong>windows or linux</strong></a> ). <br>By following these steps, we’ll create a Laravel application with a modern React Front end, fully integrated with Inertia.js and react without no starter kit.It’s RND boilerplate.</p><h3>Step 1: Installing Laravel on macOS</h3><p>First, install Laravel using the following command:</p><pre>/bin/bash -c &quot;$(curl -fsSL https://php.new/install/mac/8.4)&quot; for mac<br>/bin/bash -c &quot;$(curl -fsSL https://php.new/install/linux/8.4)&quot; for linux</pre><h3>Install Laravel Installer Globally</h3><p>To streamline Laravel project creation, install the Laravel installer globally using this command:</p><pre>composer global require laravel/installer</pre><p>For checking Laravel installer is install or not using bellow command:</p><pre>laravel -v</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t1usULVZp4tp5jGWZkjHDw.png" /></figure><p>and we can see the screen as like.</p><h3>Create a Laravel Project</h3><p>Run the following command to create a new Laravel project:</p><pre>laravel new app_name</pre><h3>Resolving Potential Errors</h3><p>if we got en error Laravel command not found or any encounter issues, update your PATH in .bash_profile or .zshrc only for macOS.</p><pre>export PATH=&quot;$HOME/.config/composer/vendor/bin:$PATH&quot;<br>source ~/.zshrc</pre><h3>Note:</h3><p>If you’re using MySQL, create a database named after your application (e.g., app_name).</p><p>Now, repeat the laravel new app_name command, and the Laravel setup should complete successfully.</p><h3>Step 2: Setting Up React with Vite</h3><h3>Install React and React DOM</h3><p>Make sure we are using Node.js version 16 or later. Then, install React and React DOM:</p><pre>npm i react react-dom</pre><h3>Install the Vite React Plugin</h3><p>Add the Vite plugin for React:</p><pre>npm install --save-dev @vitejs/plugin-react</pre><p>and update the vite.config.js file as follows:</p><pre>import { defineConfig } from &#39;vite&#39;;<br>import laravel from &#39;laravel-vite-plugin&#39;;<br>import react from &#39;@vitejs/plugin-react&#39;;<br><br>export default defineConfig({<br>    plugins: [<br>        laravel({<br>            input: &#39;resources/js/app.jsx&#39;,<br>            refresh: true,<br>        }),<br>        react(),<br>    ],<br>});</pre><h3>Step 3: Setting Up Inertia.js</h3><h3>Install Inertia Server-Side Package</h3><p>Install the Inertia server-side package for Laravel:</p><pre>composer require inertiajs/inertia-laravel</pre><h3>Update Blade Template</h3><p>Create or update resources/views/app.blade.php with the following content:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0, maximum-scale=1.0&quot; /&gt;<br>    @vite(&#39;resources/js/app.jsx&#39;)<br>    @inertiaHead<br>&lt;/head&gt;<br>&lt;body&gt;<br>    @inertia<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><h3>Create Inertia Middleware</h3><p>Generate the Inertia middleware:</p><pre>php artisan inertia:middleware</pre><blockquote>Update bootstrap/app.php to include the middleware:<br>import bellow line top of the bootstrap/app.php and add 2nd line in withMiddlewar</blockquote><pre>use App\Http\Middleware\HandleInertiaRequests;</pre><pre>$app-&gt;middleware([<br>    HandleInertiaRequests::class,<br>]);</pre><h3>Step 4: Setting Up React Client with Inertia</h3><h3>Install Inertia React Package</h3><blockquote>Install the Inertia React package:</blockquote><pre>npm install @inertiajs/react</pre><h3>Configure Client-Side Setup</h3><blockquote>Create or update resources/js/app.jsx with the following content:<br><strong>Note:</strong> we rename the `app.js to app.jsx` and its looks like bellow</blockquote><pre>import { createInertiaApp } from &#39;@inertiajs/react&#39;;<br>import { createRoot } from &#39;react-dom/client&#39;;<br><br>createInertiaApp({<br>    resolve: name =&gt; {<br>        const pages = import.meta.glob(&#39;./Pages/**/*.jsx&#39;, { eager: true });<br>        return pages[`./Pages/${name}.jsx`];<br>    },<br>    setup({ el, App, props }) {<br>        createRoot(el).render(&lt;App {...props} /&gt;);<br>    },<br>});</pre><h3>Update Vite Config</h3><blockquote>Ensure your vite.config.js includes the React plugin:</blockquote><pre>import { defineConfig } from &#39;vite&#39;;<br>import laravel from &#39;laravel-vite-plugin&#39;;<br>import react from &#39;@vitejs/plugin-react&#39;;<br><br>export default defineConfig({<br>    plugins: [<br>        laravel({<br>            input: &#39;resources/js/app.jsx&#39;,<br>            refresh: true,<br>        }),<br>        react(),<br>    ],<br>    resolve: {<br>        alias: {<br>            &quot;@&quot;: &quot;/resources/js&quot;,<br>        },<br>    },<br>});</pre><p>and also update the view/app.blade.php</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0, maximum-scale=1.0&quot; /&gt;<br>    @viteReactRefresh<br>    @vite(&#39;resources/js/app.jsx&#39;)<br>    @inertiaHead<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    @inertia<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>here we just add @viteReactRefresh top of the vite resources. we must add top of @vite(‘resources/js/app.jsx’) other wise it will show render error.</p><h3>Step 6: Adding a React Page</h3><h3>Create Pages Directory</h3><p>Create a Pages directory under resources/js/ and add a Home.jsx file:</p><pre>export default function Home() {<br>    return (<br>        &lt;&gt;<br>            &lt;div className=&quot;bg-white dark:bg-slate-800 rounded-lg px-6 py-8 ring-1 ring-slate-900/5 shadow-xl&quot;&gt;<br>                &lt;h3 className=&quot;text-slate-900 dark:text-white mt-5 text-base font-medium tracking-tight&quot;&gt;<br>                    Welcome to Inertia with React!<br>                &lt;/h3&gt;<br>                &lt;p className=&quot;text-slate-500 dark:text-slate-400 mt-2 text-sm&quot;&gt;<br>                    Your React frontend is now seamlessly integrated with Laravel.<br>                &lt;/p&gt;<br>            &lt;/div&gt;<br>        &lt;/&gt;<br>    );<br>}</pre><h3>Update Routes</h3><p>Modify routes/web.php to use Inertia:</p><pre>Route::get(&#39;/&#39;, function () {<br>    return inertia(&#39;Home&#39;);<br>});<br><br>alternative <br><br>use Inertia\Inertia;<br><br>Route::get(&#39;/&#39;, function () {<br>    return Inertia::render(&#39;Home&#39;);<br>});</pre><h3>Step 7: Running the Application</h3><p>Start the Laravel server: i used port 8004 because other already run another application. but we can run 8000 port also.</p><pre>php artisan serve --port=8004 or php artisan serve (its use port 8000)</pre><p>Run the Vite development server in a separate terminal:</p><pre>npm run dev</pre><p>Visit <a href="http://localhost:8000/">http://localhost:800</a>3 or <a href="http://localhost:8000/">http://localhost:800</a>0 to see your application in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWxAF1zXImJHmBYVPMCCaA.png" /></figure><h3>Conclusion</h3><p>Congratulations, You’ve successfully set up a Laravel project with Inertia.js and React on macOS.</p><p>Reference, check out:</p><ol><li><a href="https://laravel.com/docs/11.x/installation#installing-php">Laravel Installation Documentation</a></li><li><a href="https://laravel.com/docs/11.x/vite#react">Laravel Vite Asset Bundling</a></li><li><a href="https://inertiajs.com/server-side-setup">Inertia.js Server-Side Setup</a></li><li><a href="https://inertiajs.com/client-side-setup">Inertia.js Client-Side Setup</a></li></ol><p>Git hub link: <a href="https://github.com/Shahjalal7311/laravel_11_inretia_react"><strong>Project</strong></a></p><blockquote><strong>Note:</strong> it’s a boilerplate project without any starter kit. If have any misinformation please let us know in comment.</blockquote><p>Just i read the documentation and used all basic thing in a sample project. that its.</p><h3><strong>Thank you.</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb60a157474c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PHP __callStatic magic method and how it works?]]></title>
            <link>https://blog.devops.dev/php-callstatic-magic-method-and-how-it-works-ee4536591808?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee4536591808</guid>
            <category><![CDATA[php-development]]></category>
            <category><![CDATA[php-developers]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Mon, 15 May 2023 06:22:22 GMT</pubDate>
            <atom:updated>2023-05-15T16:46:56.488Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will learn about the PHP <em>__callStatic()</em> magic method and how to use it to make out code more flexible.</p><p>Introduction to the PHP <em>__callStatic()</em> magic method</p><p>PHP invokes the <em>__callStatic()</em> method when we invoke an inaccessible static method of a class. <em>__callStatic()</em> is triggered when invoking inaccessible methods in a static context.</p><p>The syntax of <em>__callStatic()</em> method:</p><pre>public static __callStatic(string $name, array $arguments): mixed</pre><p><em>__callStatic()</em> method has two parameters: $name and another one is $arguments.</p><p>When we call an inaccessible static method of a class, PHP will automatically invoke the <em>__callStatic()</em> method with the following arguments:</p><blockquote>1. $name parameter is static method name<br>2. $argumets parameter is array of $arguments</blockquote><p>Here is an example of __callStatic():<br>Let’s start,</p><pre>&lt;?php<br><br>class callString<br>{<br>    private static $methods = [<br>        &#39;to_upper&#39; =&gt; &#39;strtoupper&#39;,<br>        &#39;to_lower&#39; =&gt; &#39;strtolower&#39;,<br>    ];<br><br>    public static function __callStatic(string $method, array $parameters)<br>    {<br>        if (!array_key_exists($method, self::$methods)) {<br>            throw new Exception( $method . &#39; is not supported.&#39;);<br>        }<br><br>        return call_user_func_array(self::$methods[$method], $parameters);<br>    }<br>}<br><br>echo String::to_lower(&#39;CALLSTATIC METHOD&#39;) . &#39;&lt;br&gt;&#39;;<br>echo String::to_upper(&#39;Call Static Method&#39;) . &#39;&lt;br&gt;&#39;;</pre><p><strong>Reff:</strong> <a href="https://www.php.net/manual/en/language.oop5.overloading.php#object.callstatic">https://www.php.net/manual/en/language.oop5.overloading.php#object.callstatic</a></p><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee4536591808" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/php-callstatic-magic-method-and-how-it-works-ee4536591808">PHP __callStatic magic method and how it works?</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How will configure Nginx, php, mysql server with composer in EC2 or aws lightsail instence in…]]></title>
            <link>https://blog.devops.dev/how-will-configure-nginx-php-mysql-server-with-composer-in-ec2-or-aws-lightsail-instence-in-833bed463e00?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/833bed463e00</guid>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[mysql]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Wed, 04 Jan 2023 06:31:12 GMT</pubDate>
            <atom:updated>2023-01-11T14:35:32.354Z</atom:updated>
            <content:encoded><![CDATA[<h3>How will configure Nginx, php, mysql server with composer in EC2 or aws lightsail instence in ubuntu server?</h3><p>In this article, we will talk how we will setup Ubuntu server environment in EC2 and AWS lightsail instance and how we can run <strong>PHP</strong> application and make connection with <strong>MySql</strong> server. For bonus, we will talk about <strong>git</strong> and <strong>composer</strong> installation process step by step. Let’s start</p><p><strong>Step 1:</strong> <strong>Install or lunch EC2 Instence or lightsail. <br></strong>we will install Ubuntu OS(18.04 or 20.04) in any machine or lunch any EC2 Instence or lightsail(Console <a href="https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fconsole.aws.amazon.com%2Fconsole%2Fhome%3FhashArgs%3D%2523%26isauthcode%3Dtrue%26nc2%3Dh_ct%26src%3Dheader-signin%26state%3DhashArgsFromTB_ap-northeast-1_62e96e79eacce4b8&amp;client_id=arn%3Aaws%3Asignin%3A%3A%3Aconsole%2Fcanvas&amp;forceMobileApp=0&amp;code_challenge=ULBLIYsGIyg1Z1uePEoX1jeQQnrgCqUOr6VKxKEJipo&amp;code_challenge_method=SHA-256">Login</a>).</p><p><strong>Step 2: Then we logged in our newly created Instence and install basic tools like zip, unzip.</strong><br>Before installation any tools, we need to updated <strong>apt </strong>Ubuntu package management system. Because this is our first interaction with the <strong>apt</strong> package management system in this session in new Ubuntu OS.</p><p>For updating <strong>apt</strong> package management system run the command:</p><blockquote><strong>sudo apt update</strong></blockquote><p>For installing <strong>zip</strong> and <strong>unzip</strong> tools run bellow command:</p><blockquote><strong>sudo apt install zip unzip</strong></blockquote><p><strong>Step 2: </strong>Git installing</p><p>Version control systems like <strong>Git</strong> are essential to modern software development best practices. Versioning allows us to keep track of our software at the source level. we can track changes, revert to previous stages, and branch to create alternate versions of files and directories.</p><p>Installing git run the command: <strong>sudo apt install git</strong> after complete the installation we need to check that we have installed or not in our system by running the following command</p><blockquote><strong>git — version</strong></blockquote><p>and checking that you receive relevant output.</p><blockquote><strong>git version 2.38.1</strong></blockquote><p><strong>Step 3: </strong>Installing Nginx</p><p>Before installing Nginx, we need to update <strong>apt</strong> again(<strong>step: 1</strong>). After that we will install Nginx by running the command</p><blockquote><strong>sudo apt install nginx</strong></blockquote><p><strong>Step 4:</strong> Checking our Web Server or Nginx status</p><p>At the end of the installation process, Ubuntu OS starts Nginx by deafult. The web server should already be up and running.We can check web server status by run bellow command</p><blockquote><strong>systemctl status nginx</strong></blockquote><p><strong>Step 5: Managing the Nginx Process</strong></p><p>Congratulation, we have successfully install Nginx in our Ubuntu server. But Nginx have some basic process management command.</p><p><strong>In this step we will check:</strong></p><p>To stop our web server run the command: <strong>sudo systemctl stop nginx<br></strong>To Start our web server run the command: <strong>sudo systemctl start nginx<br></strong>To restart our web server run the command: <strong>sudo systemctl restart nginx</strong></p><p>If we change any thing in Nginx but we need to check that have any miss-configuration or any syntax error in Nginx.</p><p>That time we run the command: <strong>sudo nginx -t</strong></p><p>If we are only making configuration related changes in Nginx, That time we need to reload Nginx without dropping connections.</p><p>and run the command: <strong>sudo systemctl reload nginx</strong></p><p>To re-enable the service to start up at boot: <strong>sudo systemctl enable nginx</strong></p><p>If we need to disable Nginx run the command: <strong>sudo systemctl disable nginx</strong></p><p><strong>Step 6: Installing the PHP(FPM version)</strong></p><p>Here we will show two <strong>PHP</strong> version installing process <strong>PHP 8.0 and 7.4</strong></p><p><strong>6.1: First</strong> we will talk <strong>php 8.0</strong> with installing process. Let’s start</p><pre>- Install php sudo apt install php8.0-fpm php8.0-mysql<br>- Install different type php extention: sudo apt install php8.0-mbstring php8.0-xml php8.0-bcmath php8.0-simplexml php8.0-intl php8.0-mbstring php8.0-gd php8.0-curl php8.0-zip</pre><p><strong>6.2: In this step,</strong> we will talk php7.4 with installing process.Let’s start</p><pre>- Install php7.4: sudo apt install php7.4-fpm php7.4-mysql<br>- Install different type php7.4 extention: sudo apt install php7.4-mbstring php7.4-xml php7.4-bcmath php7.4-simplexml php7.4-intl php7.4-mbstring php7.4-gd php7.4-curl php7.4-zip</pre><p>So here we will describe 2 different version. But we will install any one of them.</p><p><strong>Step 7: Installing the composer</strong></p><p>For installing the composer we will run bellow command one by one:</p><pre>sudo add-apt-repository ppa:ondrej/php<br>php -r &quot;copy(&#39;https://getcomposer.org/installer&#39;, &#39;composer-setup.php&#39;);&quot;<br>php -r &quot;if (hash_file(&#39;sha384&#39;, &#39;composer-setup.php&#39;) === &#39;55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae&#39;) { echo &#39;Installer verified&#39;; } else { echo &#39;Installer corrupt&#39;; unlink(&#39;composer-setup.php&#39;); } echo PHP_EOL;&quot;<br>php composer-setup.php<br>php -r &quot;unlink(&#39;composer-setup.php&#39;);&quot;<br>sudo mv composer.phar /usr/bin/composer</pre><p>After complete the installation process we need to check composer it’s install or not by the command: <strong>composer -V</strong> or <strong>composer</strong> <br>and you have seen the output as like <strong>Composer version 2.4.0 2022–08–16 16:10:48</strong></p><p><strong>Step 8: Installing MySQL</strong></p><p>Congratulation, we have a web server(<strong>PHP, Nginx</strong>) up and running,</p><p>So now we need to install the database system to be able to store and manage data for our application. For that we install and use <strong>MySQL</strong>.<strong>MySQL</strong> is a popular database management system used within PHP environments. Let’s start</p><blockquote>Run the command: <strong>sudo apt update and sudo apt install mysql-server</strong></blockquote><p>When we’re finished the installation, Then we able to log in to the <strong>MySQL</strong> console by run the command: <strong>sudo mysql</strong></p><p>To exit the <strong>mysql</strong> console run the command: <strong>exit</strong></p><p><strong>Step 9: Configuring Nginx to Use the PHP</strong></p><p>Already, we have install <strong>Nginx, PHP, MYSQL</strong>. So in this step we have make connection between them.So let’s start</p><p>When using the <strong>Nginx</strong> web server, we can create server blocks (<strong>similar to virtual hosts in Apache</strong>) to encapsulate configuration details and host more than one domain on a single server.</p><p>Here, we’ll use <strong>own_domain</strong> as an example domain name.</p><p>Create the root web directory under <strong>/var/www/{example_dir}</strong> in here <strong>example_dir</strong> is your project directory.Run the bellow command</p><p><strong>sudo mkdir /var/www/example_dir</strong> and assign the directory owner ship by run the command <strong>sudo chown -R $USER:$USER /var/www/example_dir</strong></p><p>After that, we need to create <strong>site-available</strong> by run the command <strong>sudo vim /etc/nginx/sites-available/example_dir</strong> if <strong>vim</strong> not install your system then run the command <strong>sudo apt install vim</strong>.</p><p>Now we will create empty file under the <strong>/etc/nginx/sites-available/example_dir</strong> and copy the sample code and paste the code in blank file.The sample code is here</p><pre>server {<br>     listen 80;<br>     server_name server_domain_or_IP;<br>     root /var/www/example_dir;<br><br>     add_header X-Frame-Options &quot;SAMEORIGIN&quot;;<br>     add_header X-XSS-Protection &quot;1; mode=block&quot;;<br>     add_header X-Content-Type-Options &quot;nosniff&quot;;<br><br>     index index.html index.htm index.php;<br><br>     charset utf-8;<br><br>     location / {<br>         try_files $uri $uri/ /index.php?$query_string;<br>     }<br><br>     location = /favicon.ico { access_log off; log_not_found off; }<br>     location = /robots.txt  { access_log off; log_not_found off; }<br><br>     error_page 404 /index.php;<br><br>     location ~ \.php$ {<br>         fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; // fastcgi_pass unix:/var/run/php/php8.0-fpm.sock<br>         fastcgi_index index.php;<br>         fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;<br>         include fastcgi_params;<br>     }<br><br>     location ~ /\.(?!well-known).* {<br>         deny all;<br>     }<br> } </pre><p><strong>Save and exit</strong>.</p><p>After complete creating the <strong>site-available</strong> file activate our configuration by linking to the config file from Nginx’s sites-enabled directory. For creating the linking we run the command</p><pre>sudo ln -s /etc/nginx/sites-available/example_dir /etc/nginx/sites-enabled/</pre><p>And if we want unlink the default configure run the command</p><p><strong>sudo unlink /etc/nginx/sites-enabled/default</strong></p><p>One thing, Before Nginx reload we need to check the Nginx have any syntax errors. For checking syntax errors run the command</p><p><strong>sudo nginx -t</strong></p><p>If it doesn’t show any syntax error then run bellow command to reload the Nginx.</p><p>Command: <strong>sudo systemctl reload nginx</strong></p><p>Now our Nginx configure is complete and new website is now active, but the web root <strong>/var/www/example_dir</strong> is still empty.</p><p>So for checking, we will Create an <strong>index.html</strong> file in that location(<strong>/var/www/example_dir/index.html</strong>) so that we can test that your new server block works as expected and Include some html content or copy the bellow content and paste it into the <strong>index.html</strong>.</p><pre>&lt;html&gt;<br>    &lt;head&gt;<br>      &lt;title&gt;your_domain website&lt;/title&gt;<br>    &lt;/head&gt;<br>    &lt;body&gt;<br>      &lt;h1&gt;Hello World!&lt;/h1&gt;<br><br>      &lt;p&gt;This is the landing page of &lt;strong&gt;your_domain&lt;/strong&gt;.&lt;/p&gt;<br>    &lt;/body&gt;<br>  &lt;/html&gt;</pre><p>If want check then type your domain or ip in browser <a href="http://server_domain_or_ip./"><strong>http://server_domain_or_IP</strong>.</a> If you see this page, it means your Nginx server block is working as expected.</p><p>Congratulation, Our <strong>Nginx, PHP, MySql</strong> server is completely ready for use.</p><p><strong>Step 10: Testing PHP, Nginx with MySql</strong></p><p>Now we login our mysql console by the command <strong>sudo mysql</strong> and we can see the <strong>mysql</strong> console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBOO4lQi4mXzFc7J_nYOTg.png" /></figure><p>To create a new database, run the following command from your MySQL console: <strong>CREATE DATABASE example_database;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2t-iuqyr9Pux2sHyxXEU0Q.png" /></figure><p>Now we can create a new user and grant them full privileges on the custom database we’ve just created.</p><p>The following command creates a new user named <strong>example_user</strong>, using <strong>mysql_native_password</strong> as default authentication method. We’re defining this user’s password as password, but we should replace this value with a secure password of our own choosing.</p><pre>CREATE USER &#39;example_user&#39;@&#39;%&#39; IDENTIFIED WITH mysql_native_password BY &#39;example_user&#39;;</pre><p>So we have created database and user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iq4wLCH-MoUEixRnjv0RqQ.png" /></figure><p>Now we give full permission by run the command:</p><p><strong>GRANT ALL ON example_database.* TO ‘example_user’@’%’;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tWU65dNqmxY2YhOgyHu1yg.png" /></figure><p>and flush the all privileges by the command <strong>FLUSH PRIVILEGES;</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zpx27Y0vZlCCuaA4ZwLnjQ.png" /></figure><p>Finally we create the database and user and also give permission.So if we want to see the database list then run the command in mysql console</p><p><strong>show datbase;</strong></p><p>after that we can see the lists off databases which have we created.</p><p>That means our PHP environment is ready to connect and interact with our MySQL server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=833bed463e00" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/how-will-configure-nginx-php-mysql-server-with-composer-in-ec2-or-aws-lightsail-instence-in-833bed463e00">How will configure Nginx, php, mysql server with composer in EC2 or aws lightsail instence in…</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make Wildcard SSL Certificate in Apache in Encrypt/Certbot on CentOS?]]></title>
            <link>https://medium.com/@mdjalal2012/how-to-make-wildcard-ssl-certificate-in-apache-in-encrypt-certbot-on-centos-3e1209d96679?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e1209d96679</guid>
            <category><![CDATA[wildcard]]></category>
            <category><![CDATA[ssl-certificate]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Mon, 16 May 2022 03:54:27 GMT</pubDate>
            <atom:updated>2022-05-16T03:54:27.736Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I want to explain the process wildcard SSL certificate for a service. Recently i used this service that the why i write a short article for future use.</p><p><strong>N.B:</strong> Already have lot of article.But i describe my understand</p><p><strong>There are some step:</strong><br> 1. Install Certbot with Let’s Encrypt Client.<br> 2. Generate SSL Certificate with single and multiple domain.<br> 3. Setup auto renewal by cron job<br> 4. Check certificate status<br> 5. Delete existing certificate</p><p>Now i will explain step by step</p><p><strong>Step 1: Install Certbot with Let’s Encrypt Client</strong><br>First, we need to check <strong>mod_ssl</strong> &amp; <strong>epel-release</strong>. If have we don’t need to install.But if don’t have we need to install <strong>mod_ssl</strong> &amp; <strong>epel-release</strong> using bellow command.</p><blockquote>sudo dnf install -y epel-release mod_ssl</blockquote><p>If we install <strong>mod_ssl</strong> in very first time maybe it not enable by default. To test whether <strong>mod_ssl</strong> is enabled or not to execute command:</p><blockquote>apachectl -M | grep ssl</blockquote><p>In that case if we see no output from the above command, that mean <strong>mod_ssl</strong> is not enabled. To enable the <strong>mod_ssl</strong> module, restart our <strong>httpd</strong> Apache web server to execute bellow command.</p><blockquote>systemctl restart httpd</blockquote><p>Then, again we run <strong>apachectl -M | grep ssl </strong>command. we see some output.That mean <strong>mod_ssl</strong> is enabled.</p><p>If we’re using firewall, then we need to open HTTPS port(443). For open the port we execute the command</p><blockquote>firewall-cmd — permanent — add-port=443/tcp</blockquote><p>We need reload firewall after adding port: <strong>firewall-cmd — reload</strong><br>To check firewall port execute command</p><blockquote>sudo firewall-cmd — list-all or grep ssh /etc/services</blockquote><p>Output like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0OBeJAN3OJGfX_nMyi7lXQ.png" /></figure><p>Now we install cerbot to execute the command:</p><blockquote>sudo dnf install certbot python3-certbot-apache</blockquote><p><strong>Step 2: Generate SSL Certificate with single and multiple domain.</strong></p><p>already, we have install all necessary module for Let’s Encrypt SSL. Now generate certificate for a single domain to execute the command:</p><blockquote>certbot — apache -d domain.com</blockquote><p>For multiple domain we need to execute the command:</p><blockquote>certbot — apache -d domain.com -d <a href="http://www.domain.com/">www.domain.com</a></blockquote><p>Here domain.com =&gt; our domain name which domain we make Let’s Encrypt SSL</p><p>If we want to see all hosted domain.We need to execute the command:</p><blockquote>certbot — apache</blockquote><p>We can see the all hosted domain which have Let’s Encrypt SSL.</p><p><strong>Step 3: Setup auto renewal by cron job</strong></p><p>As we know that, The Let’s Encrypt certificates are valid for 90 days. So we need to renew the certificates before expiration date. So we can renew certificates manually to execute the command:</p><blockquote>certbot renew</blockquote><p>For auto renew we can use cron job. For automatic renew to execute the command:</p><blockquote>crontab -e</blockquote><p>and add bellow this line. Save and exist.</p><blockquote>0 0 1 */3 * /usr/bin/certbot renew &gt; /dev/null 2&gt;&amp;1</blockquote><p><strong>Step 4: Check certificate status</strong></p><p>We have successfully installed Let’s Encrypt SSL. Now we check the status of the SSL certificate by visiting this URL:</p><blockquote><a href="https://www.ssllabs.com/ssltest/analyze.html?d=domain.com">https://www.ssllabs.com/ssltest/analyze.html?d=domain.com</a></blockquote><p><strong>Step 5: Delete existing certificate</strong></p><p>For delete the certificate we have execute the command:<br>For domain: <strong>certbot delete</strong><br>For directly assign domain name: <strong>certbot delete — cert-name domain.com</strong></p><p>Reff: <a href="https://certbot.eff.org/">https://certbot.eff.org/</a></p><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e1209d96679" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Server Side Rendering (SSR) in Angular]]></title>
            <link>https://medium.com/oceanize-geeks/server-side-rendering-ssr-in-angular-e31d75f7b1d0?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/e31d75f7b1d0</guid>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Thu, 09 Jul 2020 10:02:42 GMT</pubDate>
            <atom:updated>2020-07-09T10:13:34.890Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*9FpiZ2W2XPODYvEC.png" /><figcaption>Server site rendering</figcaption></figure><p>[<strong>Note</strong>: currently I have learned the server site rendering and I am writing this article which I have learn. Please let me know if there are any mistakes or if i write any wrong information]<br>Angular application executes in the browser and rendering the pages in the DOM by user actions. In this article we will learn how to implement server site rendering in angular application very easy and simplest way. So Let’s start,</p><h3>What is Server Side Rendering (SSR)?</h3><p>Server-side rendering (SSR), is the ability of an application to contribute by displaying the web-page on the server instead of rendering it in the browser. Server-side sends a fully rendered page to the client; the client’s JavaScript bundle takes over.</p><h3>Why we use Server Side Rendering (SSR)?</h3><p>There are 3 reasons for create angular application with server side rendering.<br> 1. Search engine optimization (SEO).<br> 2. Improve performance on web and mobile.<br> 3. load the page quickly.</p><p>Most of web applications are used Client Side Rendered, that means all the necessary codes (HTML, CSS, JavaScript and others) are make bundled together and transfer to the client browser at once. It’s Depending on browser URL, frameworks like Angular, React, Vue etc.uses that code to show (browser url) different views by manipulate DOM and making network requests. In this approach user wait long time before downloaded all necessary information in client browser this user see the blank page or loader.</p><p>Basically, In angular <strong>index.html</strong> page is served from express server for all the URL paths and that <strong>index.html</strong> page is passed through some express view engine which injects HTML into &lt;app-root&gt;&lt;/app-root&gt;, based on current route and component for that route.</p><p>So, Now I will explain in step by step to implement server site rendering in angular with simple example. One thing, we use angular cli version. So please Make sure you have Angular CLI 1.6+ or latest version installed.</p><h3>Step 1: Install the Angular CLI 1.6 or updated version</h3><p>Install the <strong>angular cli</strong> globally using <strong>npm</strong>, open a terminal or console using following command for creating angular project. The command are bellow <strong>Note</strong>: If already installed angular cli then skip step 1.</p><p>npm install -g@angular/cli</p><h3>Step 2: Create Simple Application</h3><p>At First, we create an angular application with routing. We use routing because we want show to show you how server side rendering works for different URLs, we are going to import a routing module. To create an angular application with routing module automatically generated and scss style support.<br>For creating new project with necessary information will run the command</p><p>ng new angular-ssr-practice--style scss -routing</p><p>This will create angular_ssr_practice folder, where our angular code will be located. Let’s open that in sublime, vscode or your favourite code editor.</p><p>Now Let’s understand how server side rendering works. Traditionally, we used to serve entire dist folder (technically, only index.html file from dist folder) which is contains build files of our angular application. But now, we are going to create an express server which serves <strong>index.html</strong> file from <strong>dist folder</strong>.</p><p>Later, browser has the completely rendered HTML but the application will re-render (by bootstrapping) once all necessary JavaScript and CSS files are downloaded.</p><h3>Step 1: Create few Component for production ready</h3><p>Already, we have an angular application. Now, we are going to create few components with following commands.</p><p><strong>ng g c components/home — module app.module.ts<br>ng g c components/about — module app.module.ts<br>ng g c components/contact — module app.module.ts</strong></p><p>Above command, will generate home, about and contact components inside<br>src/app/components folder. After complete, we will import these components inside routing module which will be app-routing.module ts inside src/app folder.</p><pre>&lt;!-- app-routing.module.ts --&gt;</pre><pre>import { BrowserModule, BrowserTransferStateModule } from &#39;@angular/platform-browser&#39;;<br>import { NgModule } from &#39;@angular/core&#39;;<br>import { HttpClientModule } from &#39;@angular/common/http&#39;;<br>import { CommonModule } from &#39;@angular/common&#39;;<br>import { AppRoutingModule } from &#39;./app-routing.module&#39;;<br>import { AppComponent } from &#39;./app.component&#39;;<br>import { HomeComponent } from &#39;./components/home/home.component&#39;;<br>import { AboutComponent } from &#39;./components/about/about.component&#39;;<br>import { ContactComponent } from &#39;./components/contact/contact.component&#39;;</pre><pre>@NgModule({<br>   declarations: [<br>      AppComponent,<br>      HomeComponent,<br>      AboutComponent,<br>      ContactComponent<br>   ],</pre><pre>   imports: [<br>      BrowserModule,<br>      BrowserTransferStateModule,<br>      CommonModule,<br>      AppRoutingModule,<br>      HttpClientModule<br>   ],<br>   providers: [],<br>   bootstrap: [AppComponent]</pre><pre>  })</pre><pre>export class AppModule { }</pre><h3>Step2: Change generate component like home,about and contact</h3><p>In before, we are implementing different components for different routes, we need to add a <strong>router-outlet</strong> inside <strong>app.component.html</strong> and add some html code in app component as well.</p><p>Update app component in <strong>app/app.component.html</strong></p><pre>&lt;!-- <strong>app.component.html</strong> --&gt;<br>&lt;div class=&quot;content&quot; role=&quot;main&quot;&gt;<br>   &lt;div class=&quot;card-container&quot;&gt;<br>    &lt;div class=&quot;card card-small&quot; tabindex=&quot;0&quot;&gt;<br>     &lt;a routerLink=&quot;/&quot; routerLinkActive=&quot;active [routerLinkActiveOptions]=&quot;{exact: true}&quot;&gt;Home&lt;/a&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;card card-small&quot; tabindex=&quot;0&quot;&gt;<br>   &lt;a routerLink=&quot;/about&quot; routerLinkActive=&quot;active&quot;&gt;About&lt;/a&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;card card-small&quot; tabindex=&quot;0&quot;&gt;<br>   &lt;a routerLink=&quot;/contact&quot; routerLinkActive=&quot;active&quot;&gt;Contact&lt;/a&gt;           <br>&lt;/div&gt;<br>&lt;/div&gt;<br>&lt;router-outlet&gt;&lt;/router-outlet&gt;</pre><p>Update home component <strong>app/components/home.component.html and app/components/home.component.ts</strong></p><pre>&lt;!-- <strong>home.component.html</strong> --&gt;</pre><pre>&lt;h2&gt;Welcome to home section&lt;/h2&gt;<br>&lt;p&gt;<br>  Angular application executes in the browser and rendering the pages in the DOM by user actions. <br>  In this article we will learn how to implement <br>  server site rendering in angular application very easy and simplest way. So Let’s start, <br>&lt;/p&gt;</pre><pre>&lt;!-- <strong>home.component.ts</strong> --&gt;<br>import { Component, OnInit } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br>import { Title, Meta } from &#39;<a href="http://twitter.com/angular/platform-browser">@angular/platform-browser</a>&#39;;</pre><pre><a href="http://twitter.com/Component">@Component</a>({<br>  selector: &#39;app-home&#39;,<br>  templateUrl: &#39;./home.component.html&#39;,<br>  styleUrls: [&#39;./home.component.scss&#39;]<br>})<br>export class HomeComponent implements OnInit {</pre><pre>constructor(<br>    private title: Title,<br>    private meta: Meta<br>  ) { }</pre><pre>ngOnInit(): void {<br>    this.title.setTitle(&#39;Home / Angular SSR Implementing&#39;);<br>    this.meta.updateTag({<br>        &#39;description&#39;: &#39;Angular SSR Implementing&#39;<br>    });<br>  }</pre><pre>}</pre><p>Now we change about component in this file <strong>about.component.html</strong> and <strong>about.component.ts</strong></p><pre><strong>&lt;!-- components/about.component.ts</strong> --&gt;<br>&lt;h2&gt;Welcome to about section with some user info add&lt;/h2&gt;<br>&lt;div class=&quot;&quot;&gt;<br>  &lt;div *ngFor=&quot;let user of users&quot;&gt;<br>    &lt;p&gt; User Name:{{ user.name }} &lt;/p&gt;<br>    &lt;p&gt;Address: {{user.address.street}} {{user.address.suite}} {{user.address.city}} {{user.address.zipcode}}&lt;/p&gt;<br>    &lt;p&gt; User Email:{{ user.email }} &lt;/p&gt;<br>    &lt;hr&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><pre><strong>&lt;!-- about.component.ts --&gt;</strong></pre><pre>import { Component, OnInit } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br>import { Title, Meta} from &#39;<a href="http://twitter.com/angular/platform-browser">@angular/platform-browser</a>&#39;;<br>import { HttpClient } from &#39;<a href="http://twitter.com/angular/common">@angular/common</a>/http&#39;;</pre><pre><a href="http://twitter.com/Component">@Component</a>({<br>    selector: &#39;app-about&#39;,<br>    templateUrl: &#39;./about.component.html&#39;,<br>    styleUrls: [&#39;./about.component.scss&#39;]<br>})<br>export class AboutComponent implements OnInit {<br>    public users: any = [];</pre><pre>constructor(<br>        private title: Title,<br>        private meta: Meta,<br>        private http: HttpClient,<br>        private state: TransferState<br>    ) { }</pre><pre>ngOnInit() {<br>        this.title.setTitle(&#39;About Angular SSR title update&#39;);<br>        this.meta.updateTag({<br>            &#39;description&#39;: &#39;About Angular SSR description update&#39;<br>        });<br>            this.http.get(&#39;<a href="https://jsonplaceholder.typicode.com/users&#39;">https://jsonplaceholder.typicode.com/users&#39;</a>)<br>            .subscribe((users) =&gt; {<br>                this.users = users;<br>                this.state.set(STATE_KEY_USERS, &lt;any&gt;users);<br>            }, (err) =&gt; {<br>                console.log(err);<br>            });<br>        }<br>}</pre><p>Similarly, in about component, we have changed the meta tags but we are importing users data from a remote demo server. This data will be dynamically injected inside &lt;div&gt; element on the client side but we expect it to be available (already rendered) in the response from the server.<br>Finally, we are done all thing in our application at the moment,</p><p>Now we will run the bellow command</p><pre>npm run build</pre><p>When complete the command and open the project in your favourite code editor then will see the dist folder was create inside the application and also we see some build file<br>Now we can preview it by running command <strong>ng serve</strong> and view available at <a href="http://localhost:4200/">http://localhost:4200</a> server. The screen look like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ut2q2SQK-C_Fd2lYg720ug.png" /><figcaption>View</figcaption></figure><p>Note: In about component we call external API using httpclicent. For that make sure you have HttpClientModule module imported in app.module.ts, else application won’t work.</p><p>Now we click on different menu buttons to see the views are changing, We can also see meta-tags changing. But it we see the source using ctrl+u or view page source option in context menu of the browser, we can only see index.html file with empty app-root.</p><p>There is no difference between angular application <strong>without server side rendering</strong> and <strong>with server side rendering</strong> when seen from client side. But if you see source for both <strong>home</strong> and <strong>about</strong> routes, you can see meta tags are changed and application is fully rendered.</p><p>If inspect browser then you can see the changes in home and about where meta tag is different<br><strong>Home Route:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hmgcHYwYipK0uUKJGdUo9w.png" /><figcaption>Home route</figcaption></figure><p>About Route:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ebjS9_ypGR1LvjRh_9GYcg.png" /><figcaption>About route</figcaption></figure><h3>Step 3: Implement State transfer</h3><p>If we visit <a href="http://localhost:4200/about">http://localhost:4200/about</a> page, then express server will send a HTTP request to get users data and return the rendered HTML. While on browser, the same request will be made again. This is not good for user experience and will create many problems. For overcome this problem we used `state transfer` in angular details here <a href="https://angular.io/api/platform-browser/TransferState">State Transfer</a></p><p>So, we can set state of an application before that application bootstraps. This is done by BrowserTransferStateModule and ServerTransferStateModule modules.</p><p>These modules helps angular transfer state of application bootstraps on server to be transferred to the application that runs on the browser.</p><p>Now, next step is to prevent HTTP request if application state already has a key which contains some data. If that data is present, then we don’t need to make HTTP request. TransferState service provides an interface to interact with application state. Hence we need to inject it inside about.component.ts. It is available inside platform-browser module.</p><p>For state transfer we need update some code. Those here<br>&lt;! — app/component/about.component.ts →</p><pre>&lt;!-- app/component/about.component.ts --&gt;<br>import { Component, OnInit } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br>import { Title, Meta, TransferState, makeStateKey } from &#39;<a href="http://twitter.com/angular/platform-browser">@angular/platform-browser</a>&#39;;<br>import { HttpClient } from &#39;<a href="http://twitter.com/angular/common">@angular/common</a>/http&#39;;</pre><pre>// make state key in state to store users<br>const STATE_KEY_USERS = makeStateKey(&#39;users&#39;);</pre><pre><a href="http://twitter.com/Component">@Component</a>({<br>    selector: &#39;app-about&#39;,<br>    templateUrl: &#39;./about.component.html&#39;,<br>    styleUrls: [&#39;./about.component.scss&#39;]<br>})<br>export class AboutComponent implements OnInit {<br>    public users: any = [];</pre><pre>constructor(<br>        private title: Title,<br>        private meta: Meta,<br>        private http: HttpClient,<br>        private state: TransferState<br>    ) { }</pre><pre>ngOnInit() {<br>        this.title.setTitle(&#39;About Angular SSR title update&#39;);<br>        this.meta.updateTag({<br>            &#39;description&#39;: &#39;About Angular SSR description update&#39;<br>        });</pre><pre>this.users = this.state.get(STATE_KEY_USERS, &lt;any&gt;[]);<br>        if (this.users.length == 0) {<br>            this.http.get(&#39;<a href="https://jsonplaceholder.typicode.com/users&#39;">https://jsonplaceholder.typicode.com/users&#39;</a>)<br>            .subscribe((users) =&gt; {<br>                this.users = users;<br>                this.state.set(STATE_KEY_USERS, &lt;any&gt;users);<br>            }, (err) =&gt; {<br>                console.log(err);<br>            });<br>        }<br>    }<br>}</pre><p>In <strong>app.module</strong> bellow line</p><pre>import { BrowserModule, BrowserTransferStateModule } from &#39;<a href="http://twitter.com/angular/platform-browser">@angular/platform-browser</a>&#39;;<br>import { NgModule } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br>import { HttpClientModule } from &#39;<a href="http://twitter.com/angular/common">@angular/common</a>/http&#39;;<br>import { CommonModule } from &#39;<a href="http://twitter.com/angular/common">@angular/common</a>&#39;;</pre><pre>import { AppRoutingModule } from &#39;./app-routing.module&#39;;</pre><pre>import { AppComponent } from &#39;./app.component&#39;;<br>import { HomeComponent } from &#39;./components/home/home.component&#39;;<br>import { AboutComponent } from &#39;./components/about/about.component&#39;;<br>import { ContactComponent } from &#39;./components/contact/contact.component&#39;;</pre><pre><a href="http://twitter.com/NgModule">@NgModule</a>({<br>  declarations: [<br>    AppComponent,<br>    HomeComponent,<br>    AboutComponent,<br>    ContactComponent<br>  ],<br>  imports: [<br>    BrowserModule,<br>    BrowserTransferStateModule,<br>    CommonModule,<br>    AppRoutingModule,<br>    HttpClientModule<br>  ],<br>  providers: [],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><p>Create new file in <strong>/src</strong> for state transfer <strong>browser.app.module.ts</strong> paste bellow code</p><pre>&lt;!-- <strong>browser.app.module.ts</strong> --&gt;</pre><pre>import { BrowserModule } from &#39;<a href="http://twitter.com/angular/platform-browser">@angular/platform-browser</a>&#39;;<br>import { NgModule } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br>import { AppModule } from &#39;./app/app.module&#39;;<br>import { AppComponent } from &#39;./app/app.component&#39;;</pre><pre><a href="http://twitter.com/NgModule">@NgModule</a>({<br>    imports: [<br>        AppModule,<br>        BrowserModule.withServerTransition({ appId: &#39;ssr-example&#39; }),<br>    ],<br>    bootstrap: [AppComponent]<br>})<br>export class BrowserAppModule { }</pre><p>And Update<strong> main.ts</strong> in app directory</p><pre>import { enableProdMode } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br>import { platformBrowserDynamic } from &#39;<a href="http://twitter.com/angular/platform-browser-dynamic">@angular/platform-browser-dynamic</a>&#39;;</pre><pre>import { AppModule } from &#39;./app/app.module&#39;;<br>import { BrowserAppModule } from &#39;./browser.app.module&#39;;<br>import { environment } from &#39;./environments/environment&#39;;<br>import { from } from &#39;rxjs&#39;;</pre><pre>if (environment.production) {<br>  enableProdMode();<br>}</pre><pre>platformBrowserDynamic().bootstrapModule(BrowserAppModule)<br>  .catch(err =&gt; console.error(err));</pre><p>TransferState provides get method to get a state value. First parameter to get method should be a <strong>key </strong>in the state, of type StateKey. Hence need to make a key using function makeStateKey which is done in line no. 6. Second parameter of get function is default value if key does not exist in state which we set to empty array.</p><p>Later, we are checking if this.users is empty array or not, done on line no. 31. If array is empty, then make HTTP request for the users data and set the state value which is done on line no. 35. Later, when browser bootstraps the application, users data will be already in the state and it won’t have to make another HTTP request.</p><p>After this change, rebuild the application and restart express server. Now, browser should not make another HTTP request as state object will available when angular application bootstraps on the server.</p><p>After this change, rebuild the application and restart server. Now, browser should not make another HTTP request as state object will available when angular application bootstraps on the server and also if we click menu tab the browser don’t make another http request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxykQJpMmhUXaN5zAg9KDw.png" /></figure><p>Now clear the network request and click the menu I mean home and about you can see the browser don’t make another http request. Example screen is bellow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VJqI6Oqu8ZCR-mig6JcDmQ.png" /></figure><p>I have made an example GitHub <a href="https://github.com/Shahjalal7311/angular-ssr">repository</a> with all codes implemented in this article <a href="https://github.com/Shahjalal7311/angular-ssr">Link</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e31d75f7b1d0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oceanize-geeks/server-side-rendering-ssr-in-angular-e31d75f7b1d0">Server Side Rendering (SSR) in Angular</a> was originally published in <a href="https://medium.com/oceanize-geeks">Oceanize Lab Geeks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Approach to using Docker with Laravel, Nginx, and MySQL Server.]]></title>
            <link>https://medium.com/oceanize-geeks/simple-approach-to-using-docker-with-laravel-nginx-and-mysql-server-3fab25bd0c1d?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fab25bd0c1d</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Thu, 11 Jul 2019 02:36:32 GMT</pubDate>
            <atom:updated>2019-07-11T02:36:32.634Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SWInZxoKr_wSqnJ_R8HuNw.png" /></figure><h3>Simple Approach using Docker with Laravel, Nginx, and MySQL Server.</h3><p>I take a very simplistic approach to using Docker, and I want to share with you how we can too — without a bunch of overwhelming cruft. We can build hand-crafted Docker setups without any third party tools that contain what we need and nothing more.</p><p><a href="https://docs.docker.com/">Docker</a> has become a frequently used solution for deploying applications. How it simplifies running and deploying applications in ephemeral <a href="https://www.docker.com/resources/what-container">containers</a>.</p><p><a href="https://docs.docker.com/compose/">Docker Compose</a> has most simplified the development process by allowing developers to define their infrastructure, including application services, networks, and volumes, in a single file at docker composer.</p><p>In this article, we will build a web application using the Laravel framework, Nginx as the web server and MySQL as the database server, all inside Docker containers.</p><p>We will define the entire stack configuration in a docker-compose file, along with configuration files for PHP, MySQL, and Nginx.</p><p>So Let’s start</p><h3>1st Step:-Downloading and Installing Laravel with dependency</h3><p>In 1st step, we will get the latest Laravel Project and install the dependencies for the project, including <a href="https://github.com/composer/docker">Composer</a>, the application-level package manager for PHP. <br> We will install these dependencies with Docker to avoid having to install Composer globally.</p><p>1st we go to our working directory then clone the laravel project as laravel-docker`.<br> For example you can make directory in desktop or root directory or any here you want.</p><p>But my case I make directory in root .</p><pre>git clone https://github.com/laravel/laravel.git laravel-docker</pre><p>Move into the directory laravel-docker</p><pre>cd laravel-docker</pre><p>Next we install composer globally and our project using this command</p><pre>docker run --rm -v $(pwd):/app composer install</pre><p>In here we using the -v and - -rm flags with docker run to creates an ephemeral container that will be bind-mounted to our current directory before being removed. It’s will copy the contents of ~/laravel-docker directory to the container and also ensure that the vendor folder Composer creates inside the container is copied to our current or working directory.</p><h3><strong>2nd step:-Create Docker compose file</strong></h3><p>Building our applications with Docker Compose simplifies the process of setting up and versioning our infrastructure. To set up our Laravel application, we will write a docker-compose file that defines our web server, database, and application services which configuration initialise and write code docker composer.</p><p>Open our favourite terminal and run the command to create docker-compose.yml</p><pre>sudo vim  ~/laravel-docker/docker-compose.yml</pre><p>This command make new file `docker-composer.yml` in our working directory and save with exit.</p><p>In this Docker composer file we are initialling our Different service. In our application we use three service these are `app`, `webserver`,`database server`.This 3 service initialising with other configuration in `docker-composer.yml`.</p><p>In docker-compose file, define a volume called lbdata under the db service definition to persist the MySQL database:</p><pre>#MySQL Service</pre><pre>db:</pre><pre>   volumes:<br>      - lbdata:/var/lib/mysql</pre><pre>   networks:<br>     - app-network</pre><p>The volume lbdata persists the contents of the /var/lib/mysql directory present inside the container. It allows to stop and restart the db service without losing data.</p><p>At the bottom of the file(docker-composer.yml), add the definition for the lbdata volume:</p><pre>#Volumes</pre><pre>   volumes:<br>       lbdata:<br>          driver: local</pre><p>Now we are able to use the volume anywhere across the application.</p><p>Now add the db service mysql configuration in docker-composer.yml</p><pre>#MySQL Service</pre><pre>db:<br>  volumes:<br>     - lbdata:/var/lib/mysql<br>     - ./mysql/my.cnf:/etc/mysql/my.cnf</pre><p>Finally, add the following bind mounts to the app service for the application code and configuration files:</p><pre>#PHP Service</pre><pre>app:<br>  volumes:<br>    - ./:/var/www<br>    - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini</pre><pre>  networks:<br>    - app-network</pre><p>Finally, Docker Composer file look like and copy and paste bellow code in `docker-compose.yml`</p><pre>version: &#39;1.1&#39;<br>services:</pre><pre>#PHP Service<br>  app:<br>    build:<br>      context: .<br>      dockerfile: Dockerfile<br>    image: php_service<br>    container_name: app<br>    restart: unless-stopped<br>    tty: true<br>    environment:<br>      SERVICE_NAME: app<br>      SERVICE_TAGS: dev<br>    working_dir: /var/www<br>    volumes:<br>      - ./:/var/www<br>      - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini<br>    networks:<br>      - app-network</pre><pre>#Nginx Service<br>  webserver:<br>    image: nginx:alpine<br>    container_name: webserver<br>    restart: unless-stopped<br>    tty: true<br>    ports:<br>      - &quot;88:80&quot;<br>      - &quot;443:443&quot;<br>    volumes:<br>      - ./:/var/www<br>      - ./nginx/conf.d/:/etc/nginx/conf.d/<br>    networks:<br>      - app-network</pre><pre>#MySQL Service<br>  db:<br>    image: mysql:5.7.22<br>    container_name: db<br>    restart: unless-stopped<br>    tty: true<br>    ports:<br>      - &quot;1306:3306&quot;<br>    environment:<br>      MYSQL_DATABASE: laravel<br>      MYSQL_ROOT_PASSWORD: root<br>      SERVICE_TAGS: dev<br>      SERVICE_NAME: mysql<br>    volumes:<br>      - lbdata:/var/lib/mysql/<br>      - ./mysql/my.cnf:/etc/mysql/my.cnf<br>    networks:<br>      - app-network</pre><pre>#Docker Networks<br>networks:<br>  app-network:<br>    driver: bridge<br>#Volumes<br>volumes:<br>  lbdata:<br>    driver: local</pre><h3><strong>3rd step:-Creating Docker file</strong></h3><p>Docker allows us to specify the environment inside of individual containers with a <em>Dockerfile</em>. Dockerfile enables to create custom images that we can use to install software required by our application and configure settings based on our requirements.</p><p>Now we create Docker file in our working directory</p><pre>Sudo vim ~/laravel-docker/Dockerfile</pre><p>In Dockerfile we will set the base image and specify necessary command and instruction to build the Laravel application.</p><p>Copy the code and paste in Dockerfile</p><pre>FROM php:7.2-fpm</pre><pre># Copy composer.lock and composer.json<br>COPY composer.lock composer.json /var/www/</pre><pre># Set working directory<br>WORKDIR /var/www</pre><pre># Install dependencies<br>RUN apt-get update &amp;&amp; apt-get install -y \<br>    build-essential \<br>    mysql-client \<br>    libpng-dev \<br>    libjpeg62-turbo-dev \<br>    libfreetype6-dev \<br>    locales \<br>    zip \<br>    jpegoptim optipng pngquant gifsicle \<br>    vim \<br>    unzip \<br>    git \<br>    curl</pre><pre># Clear cache<br>RUN apt-get clean &amp;&amp; rm -rf /var/lib/apt/lists/*</pre><pre># Install extensions<br>RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl<br>RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/<br>RUN docker-php-ext-install gd</pre><pre># Install composer<br>RUN curl -sS <a href="https://getcomposer.org/installer">https://getcomposer.org/installer</a> | php -- --install-dir=/usr/local/bin --filename=composer</pre><pre># Add user for laravel application<br>RUN groupadd -g 1000 www<br>RUN useradd -u 1000 -ms /bin/bash -g www www</pre><pre># Copy existing application directory contents<br>COPY . /var/www</pre><pre># Copy existing application directory permissions<br>COPY --chown=www:www . /var/www</pre><pre># Change current user to www<br>USER www</pre><pre># Expose port 9000 and start php-fpm server<br>EXPOSE 9000<br>CMD [&quot;php-fpm&quot;]</pre><p>Dockerfile creates an image on top of the <a href="https://hub.docker.com/_/php/">php:7.2-fpm Docker image</a>. It’s Debian-based image that has the PHP FastCGI implementation <a href="https://php-fpm.org/">PHP-FPM</a> installed.</p><p>It’s also installs the prerequisite packages for Laravel: mcrypt, pdo_mysql, mbstring, and imagick with composer. It’s not mandatory.If anyone wants can avoided this part in docker.</p><p>The RUN directive specifies the commands to update, install, and configure settings inside the existing container.</p><p>The WORKDIR instruction specifies the /var/www directory as the working directory for the application.</p><p>We have created the <strong>www</strong> user, who has read/write access to the /var/www directory</p><p>Finally, the EXPOSE command exposes a port in the container, 9000, for the php-fpm server.</p><p>CMD specifies the command that should run once the container is created. Here, CMD specifies &quot;php-fpm&quot;, which will start the server.</p><h3><strong>4th step:-php Configuration</strong></h3><p>In this step we configuration in php infrastructure.</p><p>As purpose to create `local.ini` to over write the actual php.ini for basic changes.</p><p>So Create the php directory:</p><pre>mkdir ~/laravel-docker/php</pre><p>Then, open the local.ini file and paste the code</p><pre>upload_max_filesize=40M<br>post_max_size=40M<br>max_execution_time = 180<br>memory_limit = 3000M</pre><p>In many cases, the values you enter should get larger as you go down the list from lines one to three. The upload_max_filesize should be the smallest while memory_limit should be the largest. The median should be post_max_size.That why we change the php configuration.</p><h3>5th step:-nginx Configuring</h3><p>With the PHP service configured, we can modify the Nginx service to use PHP-FPM as the FastCGI server to serve dynamic content. The FastCGI server is based on a binary protocol for interfacing interactive programs with a web server.</p><p>[What is FASTCGI?<br> <strong>FastCGI</strong> is a <a href="https://en.wikipedia.org/wiki/Binary_protocol">binary protocol</a> for interfacing interactive programs with a <a href="https://en.wikipedia.org/wiki/Web_server">web server</a>. It is a variation on the earlier <a href="https://en.wikipedia.org/wiki/Common_Gateway_Interface">Common Gateway Interface</a> (CGI). FastCGI’s main aim is to reduce the overhead related to interfacing between web server and CGI programs, allowing a server to handle more web page requests per unit of time.<br> For more information about FastCGI please visit <a href="https://en.wikipedia.org/wiki/FastCGI">https://en.wikipedia.org/wiki/FastCGI</a></p><p>]</p><p>To configure nginx, We will create an app.conf file with the service configuration in the</p><p>So create the nginx/conf.d/ directory bellow the command</p><pre>mkdir -p ~/laravel-app/nginx/conf.d</pre><p>Then Create `app.conf` configuration file bellow the command</p><pre>sudo vim ~/laravel-app/nginx/conf.d/app.conf</pre><p>Now we add the following code to the file to specify our Nginx configuration:</p><pre><strong>server</strong> {</pre><pre><strong>listen</strong> 80;</pre><pre><strong>index</strong> index.php index.html;</pre><pre><strong>error_log</strong>  /var/log/nginx/error.log;</pre><pre><strong>access_log</strong> /var/log/nginx/access.log;</pre><pre><strong>root</strong> /var/www/public;</pre><pre><strong>location</strong> ~ \.php$ {</pre><pre><strong>try_files</strong> $uri =404;</pre><pre><strong>fastcgi_split_path_info</strong> ^(.+\.php)(/.+)$;</pre><pre><strong>fastcgi_pass</strong> app:9000;</pre><pre><strong>fastcgi_index</strong> index.php;</pre><pre><strong>include</strong> fastcgi_params;</pre><pre><strong>fastcgi_param</strong> SCRIPT_FILENAME $document_root$fastcgi_script_name;</pre><pre><strong>fastcgi_param</strong> PATH_INFO $fastcgi_path_info;</pre><pre>}</pre><pre><strong>location</strong> / {</pre><pre><strong>try_files</strong> $uri $uri/ /index.php?$query_string;</pre><pre><strong>gzip_static</strong> <strong>on</strong>;</pre><pre>}</pre><pre>}</pre><p>reference: <a href="http://nginx.org/en/docs/beginners_guide.html">http://nginx.org/en/docs/beginners_guide.html</a></p><h3><strong>6th Step:-MySql Configuration</strong></h3><p>Configure MySQL, We will make the my.cnf file in the mysql folder. This is the file that we bind-mounted to /etc/mysql/my.cnf inside the container. This bind mount allows us to override the my.cnf settings as and when required.</p><p>For Example, how it’s works, we’ll add settings to the my.cnf file that we enable the general query log and specify the log file.</p><pre>my.cnf</pre><pre>general_log = 1<br>general_log_file = /var/lib/mysql/general.log</pre><h3>7th step: — Containers Runs with Modifying Environment Settings</h3><p>In before we have configured all service in docker-compose file and created all related service. So now, we will run the Container before run the container we will make copy file .env and make changes</p><pre>cp .env.example .env</pre><p>So Now we run Docker Container bellow the command</p><pre>docker-compose up –d</pre><p>when we run the command if the command is first time run that’s time its downloaded all images form docker hub into our local machine. We need to wait sometimes. The -d flag demonises the process, running containers in background.</p><p>If we want see our running docker Container run the command</p><p>docker ps</p><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5bf4-M9P9WHg5GLWjNX5g.png" /></figure><p>After that we can modify our env file on the app container to include specific details about our setup</p><p>So, Open the file using docker-compose exec, which allows to run specific commands in containers. To modify the env using the command</p><pre>docker-compose exec app sudo vim .env</pre><p>And modify the necessary information. In my case I changes bellow blocks</p><pre>DB_CONNECTION=mysql<br>DB_HOST=db<br>DB_PORT=3306<br>DB_DATABASE=laravel<br>DB_USERNAME=roor<br>DB_PASSWORD=root</pre><p>In your case you change only DB_DATABASE, DB_USERNAME, DB_PASSWORD.</p><p>Next, set the application key for the Laravel application with the</p><p>php artisan key:generate</p><p>command. This command will generate a key and copy it to.env file, ensuring that user sessions and encrypted data remain secure.</p><p>Run the command output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FbGZzfyBD4VT4q5NTlsA9w.png" /></figure><p>We have the environment settings required to run our application. To cache these settings into a file, which will boost your application’s load speed, run:</p><pre>docker-compose exec app php artisan config:cache</pre><p>Configuration settings will be loaded into /var/www/bootstrap/cache/config.php on the container.</p><p>So, Finally visit <a href="http://localhost:88/">http://localhost:88/</a> in the. We will see the page welcome page in laravel. But my case I have some modified laravel welcome page That we can see different page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ciecH8kXKpUdVz3PVqURg.png" /></figure><p>we run laravel application using Docker. Now we move to mysql database connection and try to implement default auth using migration.</p><p>Let’s start.</p><h3>Step 8 :— MySQL Container Access by command</h3><p>To accesses MySql, execute an interactive bash shell on the db container with docker-compose exec command</p><pre>docker-compose exec db bash</pre><p>Output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vR5ZgIljXdwoo1SfmUyMqg.png" /></figure><p>We successfully login our MySql Conatiner <br>In login terminal run the command to login mysql database accesses.<br>mysql -u root –p</p><p>In this part asked authorization, the output look like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8aa_Hn1pMA9uvFAwTTopGA.png" /></figure><p>Just enter the mysql root password. By the way default password is `root`.So we type root after that we can see screen like this.</p><p>Output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-jjbr-K_9jBYcZOluW6OGQ.png" /></figure><p>Run the show databases command to check for existing databases:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NsdUfT8U6leNLKDOcsWeeg.png" /></figure><p>Output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*90lVRNWqNZZBy4pdK_yDWg.png" /></figure><p>Also we can run other command use &lt;database_name&gt; the command changes database and show tables it’s show list table in your database.</p><h3>9th step:- Laravel Data Migrating and make auth</h3><p>First, we need to test database connection to mysql by running the laravel. To check database connection we run the command</p><pre>docker-compose exec app php artisan migrate</pre><p>The command will migrated the default laravel table and the output will be</p><p>Output</p><pre>Migration table created successfully.<br>Migrating: 2014_10_12_000000_create_users_table<br>Migrated:  2014_10_12_000000_create_users_table<br>Migrating: 2014_10_12_100000_create_password_resets_table<br>Migrated:  2014_10_12_100000_create_password_resets_table</pre><p>After that we will make default auth in laravel. To make default auth we run the command</p><pre>docker-compose exec app php artisan make:auth</pre><p>Output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWUcQDZIOJ2vnJi70UZEjg.png" /></figure><p>Finally we visit the <a href="http://localhost:88/">http://localhost:88/</a> in browser we can see the home page like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6n-D_-n0LOa5d1b9zISv9g.png" /></figure><p>Some Important command</p><p>[N:B Some important command of laravel in specific container. When we change in .env or other configuration that time some operation not working properly. If not working that we can run some laravel command</p><pre>## Project Build Informatin</pre><pre>-docker-compose up --build[new build see the loger in console]<br>-docker-compose up -d [Only run the docker server like mysql, nginx and other but service run background]</pre><pre>-docker ps [check all running container]<br>-docker images [check all images in you local docker server]</pre><pre>## Database magration using docker</pre><pre>*docker-compose exec [name of container] &lt;your laravel command&gt;*<br>-docker-compose exec app php artisan cache:clear<br>-docker-compose exec app php artisan view:clear<br>-docker-compose exec app php artisan route:clear<br>-docker-compose exec app php artisan clear-compiled<br>-docker-compose exec app php artisan config:cache]</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fab25bd0c1d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oceanize-geeks/simple-approach-to-using-docker-with-laravel-nginx-and-mysql-server-3fab25bd0c1d">Simple Approach to using Docker with Laravel, Nginx, and MySQL Server.</a> was originally published in <a href="https://medium.com/oceanize-geeks">Oceanize Lab Geeks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Docker Installation with Simple Project using Docker and Pushed to Docker Hub]]></title>
            <link>https://medium.com/oceanize-geeks/basic-docker-installation-with-simple-project-using-docker-and-pushed-to-docker-hub-d319a9a7bc5b?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/d319a9a7bc5b</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-basic]]></category>
            <category><![CDATA[docker-beginner]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Tue, 25 Jun 2019 08:58:06 GMT</pubDate>
            <atom:updated>2019-06-25T08:58:06.312Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ekvovpSNUa4oOS5hIfX9g.png" /></figure><h3>What is Docker?</h3><p>Docker is not virtual machines. There’s only a single operating system running. That operating system is just carved up into isolated little spaces. A container is a self-contained sealed unit of software. It has everything in it that is needed to run that code. I mean all of it, batteries included, operating system included, it has all of the code, all of the configs, contains all the processes within that container, it has all of the networking to allow these containers to talk to the other containers they’re supposed to be able to talk to, and nothing else.</p><p>It has all the dependencies that your system needs, bundled up in that container. And it even includes just enough of the operating system to run your code. So the way it works, it takes all the services that make up a Linux server. Networking, storage, code, inter process communication, the whole works, and it makes a copy of that in the Linux Kernel for each container. So each container has its own little world that it can’t see out of, and other containers can’t see in.</p><p>Docker is a client program, named Docker, it’s a command you type at the terminal. It’s also a server program that listens for messages from that command, and manages a running Linux system. Docker has a program which builds containers from code. It takes your code along with its dependencies and bundles it up and then seals it into a container. And it’s a service that distributes these containers across the internet and makes it so you can find other’s work, and the right people can find your work.</p><p>In Docker have some key concept that is</p><p>1. Image</p><p>2. Layer</p><p>3. Container</p><h3>What is an image in Docker?</h3><p>An image is an inert, immutable, file that’s essentially a snapshot of a container. Images are created with the <a href="https://docs.docker.com/engine/reference/commandline/build/">build</a> command, and they’ll produce a container when started with <a href="https://docs.docker.com/engine/reference/commandline/run/">run</a>. Images are stored in a Docker registry such as <a href="https://registry.hub.docker.com/">registry.hub.docker.com</a>. Because they can become quite large, images are designed to be composed of layers of other images, allowing a miminal amount of data to be sent when transferring images over the network.</p><h3>What is Container in Docker?</h3><p>An instance of an image is called a container. You have an image, which is a set of layers as we describe. If we start this image, we have a running container of this image. We can have many running containers of the same image. Containers are lightweight and portable encapsulations of an environment in which to run applications.</p><h3>What is Layer in Docker?</h3><p>Basically, a layer, or <em>image layer</em> is a change on an image, or an <strong>intermediate image</strong>. Every command you specify (FROM, RUN, COPY, etc.) in your Dockerfile causes the previous image to change, thus creating a new layer.</p><p>The concept of layers comes in handy at the time of building images. Because layers are intermediate images, if you make a change to your Dockerfile, Docker will build <strong>only</strong> the layer that was changed and the ones after that. This is called layer caching.</p><p>[NB: Information Reff Link : <a href="https://docs.docker.com/v17.09/engine/userguide/storagedriver/imagesandcontainers/#images-and-layers">https://docs.docker.com/v17.09/engine/userguide/storagedriver/imagesandcontainers/#images-and-layers</a>]</p><h4>1st step:</h4><p>Install Docker form `<a href="https://docs.docker.com/docker-for-mac/install/">https://docs.docker.com/docker-for-mac/install/</a>` official website. If you have account in Docker, you can login or other end we can create new account in Docker. Before start using Docker we must login in Docker.</p><p>After install we can run the bellow command</p><p>1. docker -v we check docker version by this command.</p><p>2. docker ps we can get docker information using this command.</p><h4>2nd Step: Image to Container (the Docker flow):</h4><p>Create new image (Ubuntu or any other OS like ngnix etc) in docker run this command docker run -ti ubuntu:latest bash or If you want to create ngnix image we can run command docker run -ti ngnix:latest bash or we can specify the version docker run -ti ubuntu:14.04 bash. After finished we can see the screen as like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ho9CzqHjoKvZNI90Nns-A.png" /><figcaption>1.1</figcaption></figure><p>That mean our new Ubuntu 16.04 images was created.If we want to check of how many image exist in your Docker, we can run the command docker images</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ffnTXYiE1xLT_1OWYwX2MQ.png" /></figure><p>In my Docker have 3 images.<br>Kill the Docker image process using this command docker kill &lt;IMAGE ID&gt;<br>Start Docker by this command docker start &lt;IMAGE ID&gt;</p><p>If we want to delete or remove our image run the command. The command will work if Docker service is stop docker rmi &lt;IMAGE ID&gt;</p><p>If Docker service is start but we want to delete or remove the image we need run the command docker rmi — force &lt;IMAGE ID&gt;</p><h4>3rd Step: Create Docker container to image</h4><p>If we create Docker image from Docker container run docker ps -l here this command show last exited Docker.</p><p>In here we can see screen like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lkEr5TI3jtWtAMJsTJRBtA.png" /></figure><p>After that we can run this command docker commit &lt;DOCKER ID&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0aCKkaXmn2ipOAZzs11ZXw.png" /></figure><p>Image was created if we want check created image run this command docker images</p><p>We can see the list of images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2m5qZKrRZWGb3lI6vQGAA.png" /></figure><p>Check our active Docker by this command docker container ls If we want to check in Docker all Container run this command docker container ls -a. After That we can see list of Docker Container</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2m5qZKrRZWGb3lI6vQGAA.png" /></figure><p>Check active Docker by this command docker container ls`</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fz2QCCiYUSuAbQQb3vDybg.png" /></figure><p>If we want to check in Docker all Container run this command docker container ls -a. After That you can see list of Docker Container</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L5HWu-k16ByxnEoc9RQ7pg.png" /></figure><p><strong>Now we discussed how to run Simple html file using Docker and pushed to Docker hub</strong></p><p>First of all we create directory any where in our machine or pc. For my case I create a directory in Desktop the name docker_test.</p><p>In docker_test directory creates new file dockerfile and index.html this directory and</p><p>Add this code in dockerfile and advanced case you can set more configuration in Docker File for many other operations.</p><p>In this case we just run only html file using Docker that why we add simple code.</p><pre>FROM php:7.2-cli<br>COPY . /Applications/MAMP/htdocs/</pre><p>[in here we set your working directory]</p><p>if I work in mac os and also mamp apache server that’s why I set my working path And also add some html tag in index.html</p><p>Now We are ready to run and build simple html page using Docker.</p><p>So let’s start</p><p>Go to created directory in before where we have some file dockerfile` and index.html.You can see the list of file in our directory by this command ls</p><p>At last run the command to build project using docker</p><p>docker container run --name docker_test(Direcorty Name) -d -p 8880 -v $PWD:/user/share/nginx/html:ro -d ngionx</p><p>In browser run <a href="http://localhost:8880/">http://localhost:8880</a> we can see web page like bellow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kNG7lVfoWl_O8SNfxhkgeA.png" /></figure><p>If we terminate or kill the Docker Container Process So I want to run again Specific Docker Container Process</p><h4>How can I run the Docker container process?</h4><p>Let’s start , First we check list of all Docker container using this command docker ps -a bellow image we can see list of Docker Container</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b11IZ57raesr5qiOBUnfQg.png" /></figure><p>This image in Red line block status is up that mean this Container is currently active or running. Other Block status Exited that mean this Container is inactive.</p><p>So We are trying to start inactive container by this command docker run -it -d nginx /bin/bash or docker start &lt;CONTAINER ID&gt;</p><p>In details docker run -it -d &lt;IMAGE NAME&gt;&lt;COMMAND&gt; or docker start &lt;CONTAINER ID&gt;</p><p>If we want to kill or terminate the process run the command docker stop &lt;CONTAINER ID&gt;</p><p>Above this command we can restart or stop our Docker Container.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d319a9a7bc5b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oceanize-geeks/basic-docker-installation-with-simple-project-using-docker-and-pushed-to-docker-hub-d319a9a7bc5b">Basic Docker Installation with Simple Project using Docker and Pushed to Docker Hub</a> was originally published in <a href="https://medium.com/oceanize-geeks">Oceanize Lab Geeks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing ReactJS using webpack and babel]]></title>
            <link>https://medium.com/oceanize-geeks/installing-reactjs-using-webpack-and-babel-be2e78bffa3a?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/be2e78bffa3a</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Thu, 03 Jan 2019 10:21:49 GMT</pubDate>
            <atom:updated>2019-01-03T10:21:49.811Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to build a React.js Simple App?</h3><p>and Installing ReactJS using webpack and babel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bbLly4ZwkAW62XcVVu7Wmg.png" /><figcaption>React js App</figcaption></figure><p>In this chapter, we will show how to set up an environment for successful React development.</p><p>[N.B: At first you need to install nodejs and npm in globally in your system.]</p><p><strong>webpack</strong> is a <em>static module bundler</em> for modern JavaScript applications. When webpack processes your application, it internally builds a dependency graph which maps every module your project needs and generates one or more <em>bundles</em>.</p><p>More Details Webpack is a module bundler (manages and loads independent modules). It takes dependent modules and compiles them to a single (file) bundle. You can use this bundle while developing apps using command line or, by configuring it using webpack.config file.</p><p>[N.B: if you want to know more details about webpack please check <a href="https://webpack.js.org/">https://webpack.js.org/</a>]</p><p><strong>Babel </strong>is a JavaScript compiler<strong> </strong>and transpiler. It is used to convert one source code to other. Using this you will be able to use the new ES6 features in your code where, babel converts it into plain old ES5 which can be run on all browsers.</p><p>[N.B: if you want to know more details about babel please check <a href="https://babeljs.io/docs/en/%5D">https://babeljs.io/docs/en/]</a></p><p><strong>Step-1: Create the project directory:</strong></p><p>You need to create project directory where you want to set the project. I am Create the project in desktop using this command `sudo mkdir`.We use sudo for administration permission to set read and write permission.</p><pre>C:\Users\username\Desktop&gt;mkdir react-hello<br>C:\Users\username\Desktop&gt;cd react-hello</pre><p>After Creating the Directory, we need to create a <strong>package.json</strong> file. To do you need to run the <strong>npm init</strong> command from the command prompt. This command ask some information like package name, description, author etc.</p><p>If you skip the information write the command <strong>–y.<br></strong>Open the package json file and paste the code</p><pre>{<br>&quot;name&quot;: &quot;react-app&quot;,<br>&quot;version&quot;: &quot;1.0.0&quot;,<br>&quot;description&quot;: &quot;&quot;,<br>&quot;main&quot;: &quot;index.js&quot;,<br>&quot;scripts&quot;: {<br>    <br>},<br>&quot;keywords&quot;: [],<br>&quot;author&quot;: &quot;&quot;,<br>&quot;license&quot;: &quot;ISC&quot;<br>}</pre><h3>Step-2: install React and react dom</h3><p>Since our main task is Show hello world using Reat js, So using React js we need to <strong>install react</strong> and <strong>react-dom by </strong>commands of npm respectively also add <strong>package.json</strong> using the <strong>— save</strong> option.The Command are bellow</p><pre>C:\Users\Username\Desktop\react-hello&gt;npm install react --save<br>C:\Users\ Username\Desktop\react-hello&gt;npm install react-dom --save</pre><h3><strong>Step 3 — Install webpack</strong></h3><p>we are using webpack to generate bundler. Install webpack, webpack-dev-server and webpack-cli command are bellow</p><pre>C:\Users\username\Desktop\react-hello&gt;npm install webpack –save<br>C:\Users\username\Desktop\react-hello&gt;npm install webpack-dev-server --save<br>C:\Users\username\Desktop\react-hello&gt;npm install webpack-cli --save</pre><h3><strong>Step-4: Install babel</strong></h3><p>Install babel, and its plugins babel-core, babel-loader, babel-preset-env, babel-preset-react and, html-webpack-plugin.The command are bellow</p><pre>C:\Users\username\Desktop\react-hello&gt;npm install babel-core --save-dev<br>C:\Users\username\Desktop\react-hello&gt;npm install babel-loader --save-dev<br>C:\Users\username\Desktop\react-hello&gt;npm install babel-preset-env --save-dev<br>C:\Users\username\Desktop\react-hello&gt;npm install babel-preset-react --save-dev<br>C:\Users\username\Desktop\react-hello&gt;npm install html-webpack-plugin --save-dev</pre><h3><strong>Step-5: Create some file:</strong></h3><p>In this step, we need to create certain files namely, <strong>index.html</strong>, <strong>App.js</strong>, <strong>main.js</strong>, <strong>webpack.config.js</strong> and, .<strong><em>babelrc</em></strong>. You can create these files manually or, using <strong>command prompt</strong>.</p><h3><strong>Step 6 — Set Compiler, Server and Loaders</strong></h3><p>In this step, Open <strong>webpack-config.js</strong> file and add the following code. We are setting webpack entry point to be main.js. Output path is the place where bundled app will be served. We are also setting the development server to 8080 port. You can choose any port you want.</p><p><strong>webpack-config.js</strong></p><pre>const path = require(&#39;path&#39;);<br>const HtmlWebpackPlugin = require(&#39;html-webpack-plugin&#39;);</pre><pre>module.exports = {<br>   entry: &#39;./main.js&#39;,<br>   output: {<br>      path: path.join(__dirname, &#39;/public&#39;),<br>      filename: &#39;index.js&#39;<br>   },<br>   devServer: {<br>      inline: true,<br>      port: 8080<br>   },<br>   module: {<br>      rules: [<br>         {<br>            test: /\.jsx?$/,<br>            exclude: /node_modules/,<br>            loader: &#39;babel-loader&#39;,<br>            query: {<br>               presets: [&#39;es2015&#39;, &#39;react&#39;]<br>            }<br>         },<br>         {<br>            test: /\.css$/,<br>            use: [ &#39;style-loader&#39;, &#39;css-loader&#39; ]<br>        }<br>      ]<br>   },<br>   plugins:[<br>      new HtmlWebpackPlugin({<br>         template: &#39;./index.html&#39;<br>      })<br>   ]<br>}</pre><p>And also open package.json file and paste the code or you can see the package file look like.</p><pre>{<br>  &quot;name&quot;: &quot;recat-app&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;main&quot;: &quot;index.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;webpack-dev-server --mode development --open --hot&quot;,<br>    &quot;build&quot;: &quot;webpack --mode production&quot;<br>  },<br>  &quot;keywords&quot;: [],<br>  &quot;author&quot;: &quot;&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;,<br>  &quot;dependencies&quot;: {<br>  &quot;babel-preset-es2015&quot;: &quot;^6.24.1&quot;,<br>    &quot;react&quot;: &quot;^16.6.3&quot;,<br>    &quot;react-dom&quot;: &quot;^16.6.3&quot;,<br>    &quot;webpack-dev-server&quot;: &quot;^3.1.10&quot;<br>  },<br>  &quot;devDependencies&quot;: {<br>    &quot;babel-core&quot;: &quot;^6.26.3&quot;,<br>    &quot;babel-loader&quot;: &quot;^7.1.5&quot;,<br>    &quot;babel-preset-env&quot;: &quot;^1.7.0&quot;,<br>    &quot;babel-preset-react&quot;: &quot;^6.24.1&quot;,<br>    &quot;css-loader&quot;: &quot;^2.0.0&quot;,<br>    &quot;html-webpack-plugin&quot;: &quot;^3.2.0&quot;,<br>    &quot;style-loader&quot;: &quot;^0.23.1&quot;,<br>    &quot;webpack&quot;: &quot;^4.27.1&quot;,<br>    &quot;webpack-cli&quot;: &quot;^3.1.2&quot;<br>  },<br>  &quot;description&quot;: &quot;&quot;<br>}</pre><h3>Step 7 — index.html</h3><p>This is just regular HTML. We are setting <strong>div id = “app”</strong> as a root element for our app and adding <strong>index.js</strong> script, which is our bundled app file which file found in public/index.js.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang = &quot;en&quot;&gt;<br>   &lt;head&gt;<br>      &lt;meta charset = &quot;UTF-8&quot;&gt;<br>      &lt;title&gt;React App&lt;/title&gt;<br>   &lt;/head&gt;<br>   &lt;body&gt;<br>      &lt;div id = &quot;app&quot;&gt;&lt;/div&gt;<br>      &lt;script src = &#39;index.js&#39;&gt;&lt;/script&gt;<br>   &lt;/body&gt;<br>&lt;/html&gt;</pre><h3>Step 8: — Edit App.js and main.js</h3><p>This is the first React component. We will explain React components in depth in a subsequent chapter. This component will render <strong>Hello World</strong>.</p><h3><strong>App.js</strong></h3><pre>import React, { Component } from &#39;react&#39;;<br>class App extends Component{<br>   render(){<br>      return(<br>         &lt;div&gt;<br>            &lt;h1&gt;Hello World&lt;/h1&gt;<br>         &lt;/div&gt;<br>      );<br>   }<br>}<br>export default App;</pre><h3><strong>main.js</strong></h3><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;<br>import App from &#39;./App.js&#39;;</pre><pre>ReactDOM.render(&lt;App /&gt;, document.getElementById(&#39;app&#39;));</pre><p>Open the <strong>.babelrc </strong>file and paste the code</p><pre>{<br>    &quot;presets&quot;:[&quot;env&quot;, &quot;react&quot;]<br> }</pre><h3><strong>Step-9: Install all package and running the server using this command</strong></h3><p>npm i or npm install then npm start</p><p>You see the screen like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GCtSZLPyIl6emqyWbyiMrg.png" /><figcaption>Output</figcaption></figure><h3>Step 10 — Generating the bundle</h3><p>In this step, Generate the bundle you need to run the build command in the command prompt as npm run build</p><p>You can see the project Directory the bundle was generating</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*562Q7p918jryDTypwSeZRg.png" /><figcaption>bundle directory file</figcaption></figure><p>You successfully run your 1st React js simple application.</p><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be2e78bffa3a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oceanize-geeks/installing-reactjs-using-webpack-and-babel-be2e78bffa3a">Installing ReactJS using webpack and babel</a> was originally published in <a href="https://medium.com/oceanize-geeks">Oceanize Lab Geeks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Login with google using Socialite package in laravel-5.4 or upper version.]]></title>
            <link>https://medium.com/oceanize-geeks/login-with-google-using-socialite-package-in-laravel-5-4-or-upper-version-45ea138a739c?source=rss-98fa804cd128------2</link>
            <guid isPermaLink="false">https://medium.com/p/45ea138a739c</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Shahjalal]]></dc:creator>
            <pubDate>Mon, 10 Dec 2018 08:37:46 GMT</pubDate>
            <atom:updated>2018-12-10T08:37:46.210Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2TpR2VK5j0Rf9GymOt8QMg.png" /><figcaption>Login with google using Socialite package in laravel</figcaption></figure><p>In this section I will discuss how to login with google account in your Laravel website<strong>.</strong> Laravel 5.6 provide Socialite package that’s help to login social authentication like google, Facebook, etc. So today we discussed only Google login.</p><p><strong>Let’s follow bellow step:</strong></p><h3>Step 1: Install Socialite package</h3><p>In first we will install Socialite Package that provide google api to connect with google. So, we need to open terminal and run bellow command:</p><pre>composer require laravel/socialite</pre><p>After Complete installation the package we need to add service provider` and alias in app.php.</p><p>So go to the directory config/app.php open the file in any editor (I am using sublime 3)</p><p>Find provider put the changes in last.</p><p><strong>Providers</strong></p><pre>&#39;providers&#39; =&gt; [<br>    ....<br>    Laravel\Socialite\SocialiteServiceProvider::class,<br>]</pre><p><strong>Aliases</strong></p><pre>&#39;aliases&#39; =&gt; [<br>    ....<br>    &#39;Socialite&#39; =&gt; Laravel\Socialite\Facades\Socialite::class,<br>],</pre><p><strong>Step 2: Create Google App</strong></p><p>In google login we need google App ID and secret key for that we can get other user information. So if have no google App ID We can create App ID using this link</p><pre><a href="https://console.developers.google.com/">https://console.developers.google.com</a></pre><p>After create account you can copy App ID and App Secret Key.After that put the APP ID and Secret key in .env` file and have changes in service.php`.</p><p>Now we open service.php in directory `/config/service.php` add the bellow code in service.php</p><pre>return [<br>....<br>&#39;google&#39; =&gt; [<br>    &#39;client_id&#39; =&gt; env(&#39;GOOGLE_CLIENT_ID&#39;),<br>    &#39;client_secret&#39; =&gt; env(&#39;GOOGLE_CLIENT_SECRET&#39;),<br>    &#39;redirect&#39; =&gt; env(&#39;GOOGLE_CALLBACK_URL&#39;),<br>  ],<br>]</pre><p>And also add bellow code in .env` file</p><pre>GOOGLE_CLIENT_ID=xxxxxxxxx<br>GOOGLE_CLIENT_SECRET=xxxxxxx<br>GOOGLE_CALLBACK_URL=http://xxxxxxx/auth/google/callback</pre><p><strong>Step 3: Create Migration to Extend the user model to put new field(google_id) in user table.</strong></p><pre>&lt;?php</pre><pre>use Illuminate\Support\Facades\Schema;<br>use Illuminate\Database\Schema\Blueprint;<br>use Illuminate\Database\Migrations\Migration;</pre><pre>class CreateAddColumnUsersTable extends Migration</pre><pre>{</pre><pre>/**<br>* Run the migrations.<br>*<br>* @return void<br>*/</pre><pre>public function up()<br>{<br>  Schema::table(&#39;users&#39;, function (Blueprint $table) {<br>     $table-&gt;string(&#39;google_id&#39;)-&gt;nullable()-&gt;after(&#39;id&#39;);<br>  });<br>}</pre><pre>/**</pre><pre>* Reverse the migrations.<br>*<br>* @return void<br>*/</pre><pre>public function down()</pre><pre>{<br>  Schema::table(&#39;users&#39;, function (Blueprint $table) {<br>     $table-&gt;string(&#39;google_id&#39;)-&gt;nullable()-&gt;after(&#39;id&#39;);<br>    });<br>  }<br>}</pre><p><strong>Step 4: In this step we need to add field in user model which field added by migration. So</strong></p><p>We open the `User.php`</p><pre>&lt;?php</pre><pre>namespace App;<br>use Illuminate\Notifications\Notifiable;<br>use Illuminate\Foundation\Auth\User as Authenticatable;</pre><pre>class User extends Authenticatable{<br>   use Notifiable;</pre><pre>/**<br>* The attributes that are mass assignable.<br>*<br>* @var array<br>*/</pre><pre> protected $fillable = [<br>    &#39;name&#39;, &#39;email&#39;, &#39;password&#39;, &#39;google_id&#39;<br> ];</pre><pre>/**<br>* The attributes that should be hidden for arrays.<br>*<br>* @var array<br>*/</pre><pre>protected $hidden = [&#39;password&#39;, &#39;remember_token&#39;,];</pre><pre>public function addNew($input)<br>{<br> $check = static::where(&#39;google_id&#39;,$input[&#39;google_id&#39;])-&gt;first();<br>   if(is_null($check)){<br>      return static::create($input);<br>    }<br>   return $check;<br>  }</pre><pre>}</pre><p>Step 5: In this step we need to make new controller and method to handle google callback request and other. First make new controller <strong>GoogleController.php in bellow directory</strong></p><pre><strong>app/Http/Controllers/Auth</strong></pre><p><strong>And put the code in GoogleController.php</strong></p><pre>&lt;?php</pre><pre>namespace App\Http\Controllers\Auth;<br>use App\User;<br>use App\Http\Controllers\Controller;<br>use Socialite;<br>use Exception;<br>use Auth;</pre><pre>class GoogleController extends Controller<br>{</pre><pre>/**<br>* Create a new controller instance.<br>*<br>* @return void<br>*/</pre><pre>public function redirectToGoogle()</pre><pre>{<br>   return Socialite::driver(&#39;google&#39;)-&gt;redirect();<br>}</pre><pre>/**<br>* Create a new controller instance.<br>*<br>* @return void<br>*/</pre><pre>public function handleGoogleCallback()</pre><pre>{</pre><pre> try {</pre><pre>    $user = Socialite::driver(&#39;google&#39;)-&gt;user();<br>    $create[&#39;name&#39;] = $user-&gt;getName();<br>    $create[&#39;email&#39;] = $user-&gt;getEmail();<br>    $create[&#39;google_id&#39;] = $user-&gt;getId();<br>    $userModel = new User;<br>    $createdUser = $userModel-&gt;addNew($create);<br>    <br>   Auth::loginUsingId($createdUser-&gt;id);<br>      return redirect()-&gt;route(&#39;welcome&#39;);<br>    } catch (Exception $e) {</pre><pre>   return redirect(&#39;auth/google&#39;);<br>  }</pre><pre> }</pre><pre>}</pre><p><strong>Step 6: Create new route for google login.</strong></p><p>So We need to add route bellow file route/web.php`</p><pre>Route::get(‘google’, function () {return view(‘google’);});<br>Route::get(‘auth/google’, ‘Auth\GoogleController@redirectToGoogle’);<br>Route::get(‘auth/google/callback’,‘Auth\GoogleController@handleGoogleCallback’);</pre><p><strong>Step 6:In this step we set the google login button where we need. The code are bellow</strong></p><p>Google login button</p><pre>&lt;a href=&quot;{{ url(https://medium.com/&#39;auth/google&#39;) }}&quot; class=&quot;btn btn-primary btn-block&quot;&gt;&lt;strong&gt;Login With Google&lt;/strong&gt;&lt;/a&gt;</pre><p>After that you can able to login using google in your web site.<br>May be this article help you to make google login in laravel 5 or upper version.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45ea138a739c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oceanize-geeks/login-with-google-using-socialite-package-in-laravel-5-4-or-upper-version-45ea138a739c">Login with google using Socialite package in laravel-5.4 or upper version.</a> was originally published in <a href="https://medium.com/oceanize-geeks">Oceanize Lab Geeks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>