<?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 Murad Shukurlu on Medium]]></title>
        <description><![CDATA[Stories by Murad Shukurlu on Medium]]></description>
        <link>https://medium.com/@shukurlu-murad?source=rss-6c39e2c7d28e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*nbl3WkcI3rJJnEy0.jpg</url>
            <title>Stories by Murad Shukurlu on Medium</title>
            <link>https://medium.com/@shukurlu-murad?source=rss-6c39e2c7d28e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:21:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shukurlu-murad/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[Escaping the Spring bean Hell: Never use @Component in the Data Layer]]></title>
            <link>https://shukurlu-murad.medium.com/escaping-the-spring-bean-hell-never-use-component-in-the-data-layer-5f3a87e49cac?source=rss-6c39e2c7d28e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f3a87e49cac</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[bean-scope]]></category>
            <category><![CDATA[spring-bean-scopes]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Murad Shukurlu]]></dc:creator>
            <pubDate>Tue, 14 Oct 2025 18:35:36 GMT</pubDate>
            <atom:updated>2025-10-14T18:45:16.599Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_DOwAnk-hvYQjkPdpPMWyg.png" /></figure><p>Hello Friends,</p><p>I know this topic may sound a bit strange. In practice, we rarely see @Component used in the data layer — it’s considered a rule we follow. But every rule has a reason. Let’s discuss why.</p><p>If you’ve ever thought,</p><blockquote>“Why not just put @Component on my DTO or entity and let Spring handle it?”</blockquote><p>It’s a subtle mistake: it doesn’t break your build, it doesn’t throw an exception, but it silently pollutes your architecture and can create unexpected runtime issues.</p><p><strong>What </strong><strong>@Component Actually Does?</strong></p><blockquote>@Component annotatation asks for Spring: “Manage this class as a bean, create one instance, and inject it wherever it’s needed.”</blockquote><p>That’s perfect for services, repositories, and helper beans — classes that <strong>contain behavior</strong>.</p><p>But applying @Component to <strong>data objects</strong> (DTOs, entities, value objects) is dangerous:</p><ul><li>Spring will create <strong>singleton instances</strong> by default. (<strong>You can learn more about Spring Bean Scope</strong>)</li><li>Data objects are supposed to represent <strong>state per request</strong>.</li><li>Sharing state across requests leads to race conditions and inconsistent data.</li></ul><p><strong>Why the Data Layer Isn’t a Bean Factory</strong></p><p>Our data layer should consist of <strong>plain Java objects (POJOs)</strong>.</p><p>They don’t need Spring management. They don’t need lifecycle callbacks. They’re just containers for data.</p><p>We can consider example of a common mistake:</p><blockquote><a href="http://twitter.com/Component">@Component</a><br>public class UserDTO {<br> private String username;<br> private String email;<br>}</blockquote><p>Problem: Spring now creates a <strong>singleton </strong><strong>UserDTO</strong>. Two threads using it concurrently could overwrite each other’s data. That’s a <strong>classic recipe for Spring Bean Hell</strong>.</p><p>Instead, keep data classes simple:</p><blockquote>public class UserDTO {<br> private String username;<br> private String email;</blockquote><blockquote>// getters, setters, constructors<br>}</blockquote><p>Your <strong>controller</strong> or <strong>service layer</strong> can create these objects per request or map entities to DTOs as needed — no Spring bean required.</p><p>Annotating data objects with @Component can lead to:</p><ul><li><strong>Unexpected shared state</strong></li><li><strong>Memory bloat</strong> from unnecessary beans</li><li><strong>Testing difficulties</strong> with mocks and injections</li><li><strong>Confusing architecture</strong> for new developers</li></ul><p>Small mistakes can have <strong>big runtime effects</strong>.</p><p>The long story in the short : <strong>If a class represents data, don’t make it a Spring bean.</strong></p><p>Otherwise, you will came accross unwanted data,memory leak and that will lead very dangerous problems in silence.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f3a87e49cac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The magic of Laravel Scout (Example with Elastic Search driver)]]></title>
            <link>https://shukurlu-murad.medium.com/the-magic-of-laravel-scout-example-with-elastic-search-driver-3a677e9c1d91?source=rss-6c39e2c7d28e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a677e9c1d91</guid>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[laravel-scout]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Murad Shukurlu]]></dc:creator>
            <pubDate>Fri, 24 Feb 2023 07:02:24 GMT</pubDate>
            <atom:updated>2023-02-24T12:37:05.985Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpfynYDdChk4zCz3pGF6zQ.png" /></figure><p><strong>Hello folks,</strong></p><p>In this blog post, I am gonna give you some short information about <strong>Laravel Scout</strong> and how it works with <strong>Elastic Search drivers</strong>.</p><p>This tutorial is useful especially for Laravel developers who want to start <strong>Elastic Search with Laravel Scout</strong> and understand how Elastic Search work.</p><p>Before getting dipper I want to add some quick information about Elastic Search and Laravel Scout.</p><p><strong>Question 1: What is Elastic Search?</strong></p><p><strong>Elastic Search</strong> is a distributed search and analytics engine built on Apache Lucene, It means you can build your own search engine, and make easier your search results, Elastic Search takes care of your searching and gives you a comfortable way for what you what to find out.</p><p>Let us take a quick example:</p><p>If you have a table with billion data or you have pdf-s or other materials it is hard to go over them and find what you look up, Elastic Search takes care of them, you need to parse them into Elastic Search and let it help you for your searches!.</p><p>For additional information, you can look at the<strong> </strong><a href="https://www.elastic.co/"><strong>official site of elastic search</strong></a></p><p>There are some alternatives to Elastic Search for building your own search engines.</p><h4><a href="https://www.algolia.com/">Algolia</a></h4><h4><a href="https://www.meilisearch.com/">MeiliSearch</a></h4><p><strong>Question 2: What is Laravel Scout?</strong></p><p>As Laravel documentation said :</p><blockquote><a href="https://github.com/laravel/scout">Laravel Scout</a> provides a simple, driver based solution for adding full-text search to your <a href="https://laravel.com/docs/10.x/eloquent">Eloquent models</a>. Using model observers, Scout will automatically keep your search indexes in sync with your Eloquent records.</blockquote><p>Laravel Scout provides us with a solution for working with full-text search Engines . As We mentioned before, there are some alternatives to Elastic search and Laravel default provides us working with Algolia and MeilliSearch, For working on Elastic Search we need to install an elastic search driver for Laravel,</p><p>There are some numbers of drivers to use Elastic Search with Laravel but I prefer to use this pretty package: <a href="https://github.com/Jeroen-G/Explorer">https://github.com/Jeroen-G/Explorer</a>.</p><p>For installing this package just add this package to your dependency:</p><pre>composer require jeroen-g/explorer</pre><p>Then publish the config file</p><pre>php artisan vendor:publish --tag=explorer.config</pre><p>then change SCOUT_DRIVER into elastic adding this row to .env file</p><pre>SCOUT_DRIVER=elastic</pre><p>You can connect to Elastic Search with the config/explorer.php file</p><p>I assume you have installed Elastic Search on your local environment if not you can apply for <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html">official documentation</a>.</p><p>Let us add an example:</p><p>Think we have already an Article model with data we want to sync the model into elastic search with Laravel Scout how achieve this?</p><p>Firstly we need to add tell this model is searchable for this we need to add Searchable</p><pre>use Laravel\Scout\Searchable;<br><br>use Searchable;</pre><p>then add your model into the indexes array on the config/explorer.php file</p><pre>&#39;indexes&#39; =&gt; [<br>    \App\Models\Article::class<br>],</pre><p>That is it!</p><p>Your model has already been converted into searchable!</p><p>To sync all older data you need to run this command</p><blockquote>php artisan scout:import “App\Models\Article”</blockquote><p>If everything is good, your data from the database should sync into Elastic Search!</p><p><strong>Question 3: In every time my data changes do I need to run this import command?</strong></p><p>Surely No!, When you work with Eloquent Models Laravel Scout takes care of your data, When you deleted your items it removes them from the search engine when you add and edit it does too!</p><p>That is the magic of Laravel Scout</p><p>If Laravel Scout would not exist we needed to use Logtash to sync our data.</p><p><strong>Question 4: How to search ?</strong></p><p>You can search via this example :</p><pre>Article::search(&quot;Test&quot;)-&gt;get()</pre><p>If you need to filter additional columns you can go with</p><pre>Article::search(&quot;Test&quot;)-&gt;filter(new Term(&#39;column_name&#39;, $value))-&gt;get();</pre><p>That is the end of our posts. I hope it was helpful to you,</p><p>Please subscribe to me for further new posts.</p><p>Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a677e9c1d91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frameworkun public folderi — PHPUnit Remote Code Execution boşluğu]]></title>
            <link>https://shukurlu-murad.medium.com/frameworkun-public-folderi-phpunit-remote-code-execution-bo%C5%9Flu%C4%9Fu-f493c7ceef4c?source=rss-6c39e2c7d28e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f493c7ceef4c</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[php-security]]></category>
            <category><![CDATA[public-folder]]></category>
            <category><![CDATA[framework]]></category>
            <dc:creator><![CDATA[Murad Shukurlu]]></dc:creator>
            <pubDate>Thu, 10 Mar 2022 12:36:59 GMT</pubDate>
            <atom:updated>2022-03-10T13:13:22.555Z</atom:updated>
            <content:encoded><![CDATA[<h3>Frameworkun public folderi — PHPUnit Remote Code Execution boşluğu</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*1F9LoCHYGf9d9vkhlOefNA.jpeg" /></figure><p>Salamlar,</p><p>Bu yazıda qərara aldım ki, frameworkların arxitekturasında istifadə edilən public folderin niyə mövcud olması, olmasa hansı təhlükələrlə qarşılaşacağımız haqqında paylaşım edim , artıq bir neçə dəfə “community”-də <strong>public folderin</strong> silinib, kontentinin bir üst səviyyə folderə çıxarılmasının müzakirə edildiyinin şahidi olmuşam,bu o deməkdir ki, bu yol istifadə edilərək production layihələrdə işlədilir,</p><p><strong>Bu səbəblə bu addımın təhlükəsini, qarşılaşa biləcəyiniz problemlərlə əlaqəli qısa yazmağı düşündüm.</strong></p><p><strong>Qeyd :</strong> Həmçinin qeyd etmək istərdim ki, bir neçə il əvvəl başqa postumda bu mövzu ilə əlaqəli qısaca yazmışdım (<a href="https://shukurlu-murad.medium.com/5-frequently-faced-problems-and-their-life-saver-fixs-on-laravel-for-beginners-4be6907c7646"><strong>Bu linkdə</strong></a> — 3-cü topic) həmçinin Stack Overflow-da mövu ilə əlaqəli bir cavabım var : <a href="https://stackoverflow.com/a/52407342/8043667"><strong>https://stackoverflow.com/a/52407342/8043667</strong></a></p><p>Mövzuda ilkin olaraq istəyirəm ki, public folderin arxitekturadakı vəzifəsi haqqında qeyd edim.</p><p><strong>public folderi</strong> adındanda göründüyü kimi public-ə açılan qovluqdur bu folderin altında static fayllar və lazımı hissələrə request göndərən routing sistemi yerləşdirilməlidir. <strong>Bunun əsas səbəbi frameworkun digər core hissələrinə əlçatanlığın qarşısını almaqdır.</strong></p><p><strong>Bir neçə dəfə bir sualla qarşılaşmışam public-folderini silib bir üst səviyyə folderə atmaq nə problemi yarada bilər ki?. Burda nə təhlükə ola bilər?</strong></p><p>Əvvəla bu suala bu cür cavab verərdim ki, frameworkun qurucuları əgər ki, arxitekturada public folderinin olmasını nəzərdə tutublar mütləq ki, bir səbəbi var. Onu dəyişmək üçündə məntiqli bir səbəb lazımdır. Bu səbəb shared hostingdə layihəni install etməkdirsə bu yanaşmanı heç tövsiyyə etməzdim,<strong>çünki ən azından .htaccess faylı vasitəsi ilə public folderə yönəltmə verə bilirsiniz.</strong></p><p>İndi isə public folderin dəyişdirilməsi zamanı yaranan təhlüləkələrə nümunələr göstərək.</p><p>Yuxarıda qeyd etdiyim kimi, <strong>public folderi statik faylları özündə saxlamalıdır, frameworkun digər komponentlərinə əlçatanlığı lazım olduğu halda təmin etməlidir.</strong></p><p>Əgər public folderi olmasa ən adi halda layihənin sensetiv məlumatları olan <strong>.env</strong> faylını oxumaq mümkündür.</p><p><strong>.env faylı layihə üçün xüsusi önəm daşıyır</strong>.</p><p>Bundan başqa layihənin vendor fayllarına request göndərmək mümkündür, composer.json,blade komponentləri xakerlər üçün layihəniz haqqında məlumat toplamağa yardımçı olacaq.</p><p>composer.json ilə layihədə işlənən vendorları öyrənib həmin liblərin boşluqlarını istifadə edə bilərlər.</p><p>vendor faylları vasitəsi ilə birbaşa vendor fayllarına request etmək mümkündür.</p><p>Qeyd etmək istəyərdim vendor fayllarının əlçatan olması ilə xakerlər, bir neçə il öncə aktiv şəkildə layihələri ələ keçirirdilər.</p><p>PhpUnitdə olan boşluğu <strong>(PHPUnit Remote Code Execution)</strong> istifadə edən xakerlər vendor fayllarına icazəsi olan istənilən sistemdə POST sorğu göndərərək öz kodlarını server tərəfdə icra edirdilər. Daha ətraflı <a href="https://www.acunetix.com/vulnerabilities/web/phpunit-remote-code-execution/">link</a> vasitəsi ilə baxa bilərsiniz.</p><p>Qeyd etdiyim boşluqları istifadə edən <strong>xakerlər botlar vasitəsi ilə</strong> <strong>public folderi olmayan saytları aşkar edib</strong> onların səlahiyyətlərini ələ keçirdərək coin maning edirdilər, email sistemini ələ keçirdib spam emaillərində istifadə edirdilər.</p><p>Şübhəsiz ki, PHPUnit kimi geniş şəkildə işlədilən paketdə mövcud olan boşluq digər paketlərdədə bu halın olmayacağını istisna etmir. Buna görədə paketlərə birbaşa accessin dayandırılmasına mütləq şəkildə ehtiyac var.</p><p>Bəzən yoldaşlar .env faylına və vendor fayllarına .htaccess vasitəsi ilə qadağa əlavə etməyin problemi həll etdiyi barədə bildirirlər.Lakin bu yenədə problem yaradır. Çünki layihənin bütün folderlərinə icazələr tətbiq etmək həm yorucudur həmdə bu funksionallıqlarda olan problemi hələ həll etmir.</p><p>Məsələn public folder olmasa Laravel frameworkda-</p><blockquote>php artisan storage:link və php artisan serve</blockquote><p>əmrləri işləməyəcək. Çünki frameworkun defaultları var bunları dəyişiriksə lazımlı digər hissələridə dəyişməyə ehtiyac yaranır.</p><p>Yuxarıda qeyd etdiklərim ümid edirəm ki, public folderini silməmək üçün kifayət edən səbəblərdir.</p><p>Bəs əgər daha əvvəlcədən public folderi silinibsə onu necə bərpa edə bilərik?.</p><p>Bunun üçün Stack Overflowda <a href="https://stackoverflow.com/a/52407342/8043667">cavabıma</a> baxa bilərsiniz.</p><p>Əgər public folderi öz layihənizdə gizlətmək istəyirsinizsə Root icazəsiniz olan servedə Nginx və ya Apache configləri ilə public folderinə yönəltmə verərək məsələni həll edə bilərsiniz.</p><p>Shared serverdə .htaccess faylı vasitəsi ilə (server admininiz ilədə danışa bilərsiniz) aşağıdakı kodu istifadə edə bilərsiniz.</p><blockquote><em>&lt;</em><strong><em>IfModule </em></strong><em>mod_rewrite.c&gt;<br></em><strong><em>RewriteEngine </em></strong><em>On</em></blockquote><blockquote><strong><em>RewriteRule </em></strong><em>^(.*)$ public/$1 [L]<br>&lt;/</em><strong><em>IfModule</em></strong><em>&gt;</em></blockquote><blockquote><strong><em>RewriteRule </em></strong><em>^/public/?(.*) https://%{SERVER_NAME}/$1 [R,L]</em></blockquote><p>Ümid edirəm ki, yazı faydalı oldu.</p><p>Hər hansı bir şərhiniz olarsa xahiş edirəm mənimlə <a href="https://www.linkedin.com/in/murad-shukurlu-b55798b6/">əlaqə</a> saxlaya bilərsiniz.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f493c7ceef4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Open Edx journey in 2022]]></title>
            <link>https://shukurlu-murad.medium.com/my-open-edx-journey-in-2022-ad8f3a8ad1d1?source=rss-6c39e2c7d28e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad8f3a8ad1d1</guid>
            <category><![CDATA[open-edx]]></category>
            <category><![CDATA[edx]]></category>
            <dc:creator><![CDATA[Murad Shukurlu]]></dc:creator>
            <pubDate>Wed, 02 Mar 2022 06:19:56 GMT</pubDate>
            <atom:updated>2026-02-18T11:34:17.473Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*fliRDmNU1M8fhSuIkmTm4A.jpeg" /></figure><p>Hello Friends,</p><p>I am going to share my experiences over the <strong>Open Edx platform </strong>as a developer,</p><p>The main purpose of this article is,<strong> if you came across Open Edx</strong>, How you can handle it. While working on it, I faced many issues, I reported some issues, And I got many barriers that prevent me from solving issues quickly, So I want to share my experiences with you, <strong>I hope this article maybe a guide for you if you are a newbie on Open Edx</strong>.</p><p>Firstly, I would like to write some information <strong>about Open Edx</strong>, and what is it?.</p><p><strong>Open Edx is the </strong><a href="https://github.com/openedx/edx-platform"><strong>open-source code</strong></a> base of the edx.org project written in Python backend, Open Edx is working with its environment in Linux server, <a href="https://edx.org/">Edx</a> is a worldwide eLearning system in which teachers can create their own content and students can join the lessons from distance, online.</p><p>Last month I got tasked with research for upgrading our ready but old version Open Edx version to the latest version and adding some new features for it.</p><p>Although before I had experiences on Open Edx in the 2018 years. In the terms, I just had installed and made some features for the custom Open Edx platform. But It got limited experiences with it.</p><p>After that, for years many things changed, Open Edx has been released for new versions even its source codes changed from Python 2 to Python 3.</p><p>It was a challenge for me to upgrade the old system to the latest version, but it was a task that I need to handle.</p><p>First of all, I searched what was changed during those years?.</p><p>And searched upgrade ways, I found some discussion links and talked experienced ones, All of them said to me, you need to upgrade all of the versions from one by one but they said me they have really no experience in such type of task, and they were disappointed me for not tackling this challenge,</p><p>I ignored all and started learning Open Edx more closely, Firstly I build a fresh latest version Open Edx platform and tested it, I found Open Edx community uses a new way for installing Open Edx <strong>using docker</strong> by a tool named <a href="https://docs.tutor.overhang.io/"><strong>Tutor</strong></a>, I had read all documentation of tutor from start to end for times, Finally, I installed a new tutor based Open Edx platform on my computer, as the next challenge I started to upgrade our old custom template to be worked on the latest version,</p><p>I saw many things changed based on the template, our old template had not worked in the latest version due to breaking changes, there I had many issues related to old python packages, changed HTML structures, changed Django template codes and etc, I tried to review the latest version of <a href="https://github.com/openedx/edx-platform/tree/master/lms/templates">edx-platform’s template</a> and I found ways for refactoring old school codes to new ones while reviewing base codes, After all, that is it, I upgraded successfully the template as working latest edx version, But In this case, there was a problem, where is the old data?. It was the main challenge, so for years Openedx changed its database structure, Even the installation way of it changed from native installation to docker based, It was a really terrible everything works perfectly and upgraded but without old data :),</p><p>In the second attempt, I created some scripts and used SQL&#39;s power for copying the necessary data for the new system (some of them were copied by manual),</p><p>After upgrading, I still had tasks to solve, I started to explore source codes of edx-platform, I found ready APIs has written using Django Rest Framework,</p><p>I analyzed the source code of the project, although my main experience is about Java and PHP I understand the schema and applied my codes there.</p><p>And I would like to emphasize this <a href="https://courses.edx.org/api-docs/">swagger documentation</a> (<a href="https://courses.edx.org/api-docs/">https://courses.edx.org/api-docs/</a>) helped me a lot :),</p><p>I reviewed codes of Edx’s source and I had succeeded in all of my tasks finally,</p><p>During this quick period, I found some issues on the tutor side and I reported them.</p><ol><li><a href="https://discuss.overhang.io/t/can-not-sign-in-with-tutor-dev-start-command/2328">https://discuss.overhang.io/t/can-not-sign-in-with-tutor-dev-start-command/2328</a></li><li><a href="https://github.com/overhangio/tutor/issues/566">https://github.com/overhangio/tutor/issues/566</a></li></ol><p>After this quick topic, I am happy to solve all my tasks and meet with Open Edx although it had terrible for me for a while :),</p><p>In the last words, I would like to share some links which may be helped you in your first Open Edx attempts, Please feel free to share your comments below, and don&#39;t hesitate to rich me asking something I can help you.</p><p>Sincerely, From Azerbaijan</p><p>https://openedx.slack.com</p><p><a href="https://docs.tutor.overhang.io/">https://docs.tutor.overhang.io</a></p><p><a href="https://discuss.overhang.io/">https://discuss.overhang.io</a></p><p><a href="https://blog.lawrencemcdaniel.com/category/open-edx/">https://blog.lawrencemcdaniel.com/category/open-edx</a></p><p>https://discuss.openedx.org</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad8f3a8ad1d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VueJs,Axios how to redirect unauthenticated users by API to login page in the best practice?]]></title>
            <link>https://shukurlu-murad.medium.com/vuejs-axios-how-to-redirect-unauthenticated-users-by-api-to-login-page-in-the-best-practice-7c3d841b36b8?source=rss-6c39e2c7d28e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c3d841b36b8</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[axios]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[laravel-sanctum]]></category>
            <dc:creator><![CDATA[Murad Shukurlu]]></dc:creator>
            <pubDate>Wed, 30 Dec 2020 13:22:00 GMT</pubDate>
            <atom:updated>2020-12-30T19:22:38.383Z</atom:updated>
            <content:encoded><![CDATA[<h3>VueJs,Axios how to redirect API unauthenticated users to login page in the best practice?</h3><p>Hello friends,</p><p>While Single Page Application’s usage increase day-by-day one another problem also growing on developer’s mind:</p><p>Security , authentication ..</p><p>How to prevent user see our frontend app while API return unauthenticated response?.</p><p><strong>The main problem is, if you are storing any data in user’s computer for checking what user need to see on the frontend , they may change the value and see your app.This is a big deal for Hackers!</strong></p><p>In this post I dont want to talk about how to build backend , what is token and other related issues.</p><p>I want to write about how you redirect easily your unauthenticated or forbidden users while your Backend returned as unauthenticated or forbidden status (for example status 401 or 403)?.</p><p>I have see many code blocks they are using Promise’s catch block for redirect to login page in every API call, it is pain ,If you have multiple APIs in your code base this point will increase your application with redundant codes and every changes on your codes must be done in every API, this is unimportant.</p><p>You can add just some lines and fix this with your Axios instance ,</p><p>Determine you have Api.js and it contain such type codes :</p><pre>import <strong><em>axios </em></strong>from &#39;axios&#39;<br>import <strong><em>router </em></strong>from &quot;../router&quot;;<br>const <strong><em>Api </em></strong>= <strong><em>axios</em></strong>.create({<br>    baseURL:&#39;http://127.0.0.1:8001/api/&#39;<br>});</pre><pre>export default <strong><em>Api</em></strong>;</pre><p>You just add few lines as below:</p><pre>import <strong><em>axios </em></strong>from &#39;axios&#39;<br>import <strong><em>router </em></strong>from &quot;../router&quot;; // I assume you have router module<br>const <strong><em>Api </em></strong>= <strong><em>axios</em></strong>.create({<br>    baseURL:&#39;http://127.0.0.1:8001/api/&#39;<br>});<br>// those lines will catch your 401 status returend requests <br><strong><em>Api</em></strong>.interceptors.response.use(function (response){<br>    return response;<br>},function (error)<br>{<br>   if(error.response.status)<br>   {<br>       <strong><em>localStorage</em></strong>.removeItem(&#39;auth&#39;); //if you are using state or //something else to store auth status then remove it regarding your &#39;&#39;choose <br><br>       <strong><em>router</em></strong>.push(&#39;login&#39;) // I assume you have login named router<br>   }<br>});<br>export default <strong><em>Api;</em></strong></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c3d841b36b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel 8 — Model Based Factories is Amazing.]]></title>
            <link>https://shukurlu-murad.medium.com/laravel-8-model-based-factories-is-amazing-45a7450aecd2?source=rss-6c39e2c7d28e------2</link>
            <guid isPermaLink="false">https://medium.com/p/45a7450aecd2</guid>
            <category><![CDATA[eloquent]]></category>
            <category><![CDATA[laravel-framework]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Murad Shukurlu]]></dc:creator>
            <pubDate>Fri, 18 Dec 2020 21:21:44 GMT</pubDate>
            <atom:updated>2020-12-27T10:51:03.117Z</atom:updated>
            <content:encoded><![CDATA[<h3>Laravel 8 — Class Based Factories is Amazing.</h3><p>Hi friends,</p><p>Already a while before Laravel 8 version introduced. This major version contain many new and great stuffs for making Laravel more strong.</p><p>You can see all updates of <strong>Laravel 8</strong> via <a href="https://laravel.com/docs/8.x/releases"><strong>this link</strong>.</a> On this post we shell discuss just one of the new features— <strong>Class Based Factories.</strong></p><p>The main reason of my writing about this functions is — Already Laravel 8 introduced a while some friends have trouble for making relationship between factories and they surprised by seeing new code styles of factory classes due to architectural changes (many people even dont know about Laravel 8 changed factory’s main working idea although Laravel note this detailed on its documentation as all features of it as habit).</p><p>For not losing time I will add some examples both old school style and new school style. Look at my example:</p><p>Assume you have two factories for User and Task models regarding to UserFactory and TaskFactory</p><p>Note : there are hasMany relationships between User and Task models on my example.</p><p>Before class based factories launced assume you would like to make User and Task factories then you should create codes such :</p><p>User Factory :</p><blockquote>&lt;?php</blockquote><p>…</p><p>…</p><blockquote>$factory-&gt;define(User::class, function (Faker $faker) {<br>return [<br> &#39;name&#39; =&gt; $this-&gt;faker-&gt;name,<br> &#39;email&#39; =&gt; $this-&gt;faker-&gt;unique()-&gt;safeEmail,<br> &#39;email_verified_at&#39; =&gt; now(),<br> &#39;password&#39; =&gt; &#39;$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi&#39;, // password<br> &#39;remember_token&#39; =&gt; Str::<em>random</em>(10),<br>];;});</blockquote><p>TaskFactory :</p><blockquote>&lt;?php</blockquote><p>…</p><p>…</p><blockquote>$factory-&gt;define(Task::class, function (Faker $faker) {<br>return [<br>‘description’=&gt;$this-&gt;faker-&gt;text,<br>‘deadline’=&gt;$this-&gt;faker-&gt;dateTimeBetween(‘now’,’+1 years’)<br>];;});</blockquote><p>DatabaseSeeder.php</p><blockquote>….</blockquote><blockquote>public function run() {</blockquote><blockquote>factory(\App\Models\User::class,6)</blockquote><blockquote>-&gt;create()</blockquote><blockquote>-&gt;each(function ($user)</blockquote><blockquote>{</blockquote><blockquote>factory(\App\Models\Task::class,6)</blockquote><blockquote>-&gt;make()</blockquote><blockquote>-&gt;each(function ($task) use ($user)</blockquote><blockquote>{ $user</blockquote><blockquote>-&gt;task()</blockquote><blockquote>-&gt;save($user); //define hasMany relationship</blockquote><blockquote>});</blockquote><blockquote>});</blockquote><blockquote>}</blockquote><blockquote>….</blockquote><p>This looking is bored , not good and clearified.</p><p>But Class based factories offer us more comfortable way to done this task.</p><p>class based factories giving as a good architecture which we can define our factory model in a protected valuable and defining body of factory within class’s function , for example :</p><pre>protected $model = Task::class;</pre><pre>public function definition()<br>{<br>    return [<br>        &#39;description&#39;=&gt;$this-&gt;faker-&gt;text,<br>        &#39;deadline&#39;=&gt;$this-&gt;faker-&gt;dateTimeBetween(&#39;now&#39;,&#39;+10 years&#39;)<br>    ];<br>}</pre><p>Now we define our model based factories:</p><p>TaskFactory</p><pre>&lt;?php<br><br>namespace Database\Factories;<br><br>use App\Models\Task;<br>use Illuminate\Database\Eloquent\Factories\Factory;<br>class TaskFactory extends Factory<br>{<br>    <em>/**<br>     * The name of the factory&#39;s corresponding model.<br>     *<br>     * </em><strong><em>@var </em></strong><em>string<br>     */<br>    </em>protected $model = Task::class;<br><br>    <em>/**<br>     * Define the model&#39;s default state.<br>     *<br>     * </em><strong><em>@return </em></strong><em>array<br>     */<br>    </em>public function definition()<br>    {<br>        return [<br>            &#39;description&#39;=&gt;$this-&gt;faker-&gt;text,<br>            &#39;deadline&#39;=&gt;$this-&gt;faker-&gt;dateTimeBetween(&#39;now&#39;,&#39;+30 years&#39;)<br>        ];<br>    }<br><br>}</pre><p>UserFactory</p><pre>&lt;?php<br><br>namespace Database\Factories;<br><br>use App\Models\User;<br>use Illuminate\Database\Eloquent\Factories\Factory;<br>use Illuminate\Support\Str;<br><br>class UserFactory extends Factory<br>{<br>    <em>/**<br>     * The name of the factory&#39;s corresponding model.<br>     *<br>     * </em><strong><em>@var </em></strong><em>string<br>     */<br>    </em>protected $model = User::class;<br><br>    <em>/**<br>     * Define the model&#39;s default state.<br>     *<br>     * </em><strong><em>@return </em></strong><em>array<br>     */<br>    </em>public function definition()<br>    {<br>        return [<br>            &#39;name&#39; =&gt; $this-&gt;faker-&gt;name,<br>            &#39;email&#39; =&gt; $this-&gt;faker-&gt;unique()-&gt;safeEmail,<br>            &#39;email_verified_at&#39; =&gt; now(),<br>            &#39;password&#39; =&gt; &#39;$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi&#39;, // password<br>            &#39;remember_token&#39; =&gt; Str::<em>random</em>(10),<br>        ];<br>    }<br>}</pre><p>Call it in everywhere you want just one line with more simple code!</p><pre>User::<em>factory</em>(10)<br>-&gt;has(Task::<em>factory</em>()<br>-&gt;count(5))<br>-&gt;create();</pre><p>As you can see , Laravel Class Factories offer this amazing way, I really loved it , it will reduce a lot time while writing factories, it will be more readible. If you still not use class based factories try it and make your codes great!.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45a7450aecd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Benefits of Laragon]]></title>
            <link>https://shukurlu-murad.medium.com/benefits-of-laragon-e9294aa34a80?source=rss-6c39e2c7d28e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9294aa34a80</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Murad Shukurlu]]></dc:creator>
            <pubDate>Thu, 11 Apr 2019 09:59:18 GMT</pubDate>
            <atom:updated>2019-06-01T09:08:57.532Z</atom:updated>
            <content:encoded><![CDATA[<p>In the first word, Laragon is a GUI desktop application which provides developers with a working environment like XAMPP, HOMESTEAD and etc.</p><p>As a developer, I am going to make my coding environment comfortable. I want to focus my codes during coding. Getting Stuck to other works really is time wasting (for example building local web server, working with a non-productive terminal). When I got familiarity with laragon I really become a more productively developer :).</p><p>Laragon has a little problem that it only works natively on Windows OS.</p><p>I don&#39;t want to extend this topic more. See laragon’s benefits as below.</p><ol><li>Multi PHP version support</li><li>CMDER terminal support</li><li>Laragon provides us a strong database management system with HeidiSql, optionally you can change it for phpmyadmin.</li><li>SSL activation</li><li>Choosing Apache, Nginx for your web server.</li><li>Activating Memcache, Redis</li><li>Quick app creating with GUI application</li><li>Changing ports very quickly and easily</li><li>Sharing your local site for the public with Ngrok on laragon</li><li>Email management</li><li>Powerful universal development environment for PHP, Node.js, Python, Java, Go, Ruby. It is fast, lightweight, easy-to-use and easy-to-extend.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9294aa34a80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 frequently faced problems and their life saver fixs on Laravel for beginners]]></title>
            <link>https://shukurlu-murad.medium.com/5-frequently-faced-problems-and-their-life-saver-fixs-on-laravel-for-beginners-4be6907c7646?source=rss-6c39e2c7d28e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4be6907c7646</guid>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[laravel-issue]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Murad Shukurlu]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 10:41:03 GMT</pubDate>
            <atom:updated>2019-01-30T13:45:15.474Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog post i am going to talk about some encountered technical problems on Laravel for beginners. You feel free yourself to give any recommendation and correction for this article.</p><p><strong>Content :</strong></p><ol><li>HTTP 500 ERROR</li><li>RuntimeException No application encryption key has been specified.</li><li>php artisan serve — No Such file or directory</li><li>How to hide public folder?</li><li>CSRF Protection</li></ol><p>Before start for talking fixes . I would like to emphrize those 5 isues is not bug of Laravel . Each of them has their reason why they occur . During fixes problem i will try to talk about shortly what is the reason .</p><p><strong>I would like to empharize every problem occured by laravel storing its logs to file under /storage/logs/laravel.log path I recommand u can look at there if you have not find any solution for your issue between our issues list .My mean anyway you may able to find any log there if you have been meet a problem morever my guide gives you a short way to find solution qucikly.</strong></p><p><strong>1.HTTP 500 ERROR</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cstJ8FVd9yJPUbfWBTeINA.png" /></figure><p>If you are facing such type error on Laravel version above 5.5 or equal . First thing is to check php version of server . If your server using PHP version under 7 probably the issue related with php version . Dont forget Laravel uses at least PHP 7, and 7.1.3 regarding to its versions 5.5 and 5.6,5.7 .</p><p>If it doesnot work yet on the right version you can check if your dependiences really installed or not?</p><p>This may be causing by uncompleted installiation .Mainly when u pull a repo by git you need to reinstall all packages via composer .</p><p>For installing packages run this command on termial:</p><blockquote>composer install</blockquote><p>If again you are not get success then check log file of laravel via folder</p><blockquote>/storage/logs/log.txt</blockquote><p>If there is no use again you must be look at your server-side logs (this is <strong>deep note</strong> that you may can see all errors instead of this 500 error page on browser while enabling <strong>error_reporting</strong> and <strong>display_error</strong> on your <strong>php.ini</strong> file but this way is not recommand in prodaction)</p><p><strong>2. RuntimeException No application encryption key has been specified.</strong></p><p>If you see this error while you launching your site dont worry just try to run those commands .</p><blockquote>php artisan key:generate</blockquote><blockquote>php artisan config:cache</blockquote><p><strong>3.php artisan serve No such file or directory</strong></p><p>One time i faced with the question from one of my virtual friend he asked me why this problem grown? while revening of his codes i found he have a big problem becuase he have been delete public folder of laravel architectura.So that when he want to start laravel local server its server could not start to work with php artisan serve command. This is really critical problem. There is a reason why public folder is exist there .Both public folder include front side of the project and it has security responsibilty .So when developer removing public folder and move the core files to one folder above . Then core files , logs , blade themplates is reachable by attackers .The getting datas may be used for hacking your site . Dont forget if you have move your index.php files form public folder may be your .env file and <strong>its critical </strong>content is available by someone just look at this address for testing <a href="http://yourdomain.com/.env."><strong>http://yourdomain.com/.env</strong></a><strong> .</strong></p><p>I suggest you get your public folder back and use it as a main folder of your site . I suggest you look at <a href="https://stackoverflow.com/questions/52406258/missing-public-folder-in-laravel/52407342#52407342">this topic</a> and <a href="https://stackoverflow.com/a/52407342/8043667">my answer</a> on stackoverflow .</p><p>4.How to hide public folder? — is a good question .</p><p>If you have already read previous centence of my post i have talked about its negative side when <strong>laravel public folder</strong> hiding by wrong ways .</p><h3>I dont recommand to anyone remove public folder for using in best practise .</h3><p>If you have made it on your old projects and <strong>you want to protect your system</strong> i just recommand u can protect your all critical files , folders by forbidden error by .htaccess . If you have effort you can <strong>get back your public foder</strong> firstly.</p><p>For denying any file you can use this .htaccess rule (in this example .env is denyed file name) :</p><blockquote>&lt;<strong>Files </strong>&quot;.env&quot;&gt;<br> <strong>Order </strong>Allow,Deny<br> <strong>Deny </strong>from all<br>&lt;/<strong>Files</strong>&gt;</blockquote><p>In my case the correct way of hidding public folder is configure your main folder to the “public” folder via your nginx , apache configration .</p><p>I want to make a note for easy way to solv this problem .</p><p>You can create<strong> .htaccess </strong>file in your root folder and add those content there :</p><blockquote>&lt;<strong>IfModule </strong>mod_rewrite.c&gt;<br> <strong>RewriteEngine </strong>On<br><br> <strong>RewriteRule </strong>^(.*)$ public/$1 [L]<br>&lt;/<strong>IfModule</strong>&gt;<br><br><strong>RewriteRule </strong>^/public/?(.*) https://%{SERVER_NAME}/$1 [R,L]</blockquote><p>Try again reloading your site without public folder</p><p>5.CSRF token missing (Cross Site Request Force) .</p><p>I think even beginner level developers already know when this error grown and how they can fix it (This is a great stuff require us using csrf field)</p><p>This error grown when you apply with post request to a page due to missing csrf token .</p><p>Csrf mean is CROSS SITE REQUEST FORCE this is a security vulnerability name . Attacker can be reset your user’s password , update informations even can be delete all of important datas if we dont use csrf protection . (You can look for about csrf vulnerability if you interest about it on Google)</p><p>The error says us we need to use csrf protection on our post request . This investigate our request from attackers request . While you missing csrf field gives you this error .</p><p>The solution is very simple you can add only this line between your form tag</p><blockquote>{{csrf_field()}}</blockquote><p>For example :</p><blockquote>&lt;form action=”” method=”POST”&gt;</blockquote><blockquote>{{csrf_field()}}</blockquote><blockquote>&lt;input name=”name” /&gt;</blockquote><blockquote>&lt;button type=”submit”&gt;&lt;/button&gt;</blockquote><blockquote>&lt;/form&gt;</blockquote><p>I hope this article had been usefull for you . Please make a clap and note your comments to this article for improving this article and nexts .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4be6907c7646" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Powerfull Shall for Windows .]]></title>
            <link>https://shukurlu-murad.medium.com/powerfull-shell-for-windows-39d74e87c3d9?source=rss-6c39e2c7d28e------2</link>
            <guid isPermaLink="false">https://medium.com/p/39d74e87c3d9</guid>
            <category><![CDATA[programmer]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Murad Shukurlu]]></dc:creator>
            <pubDate>Sat, 12 Jan 2019 14:01:23 GMT</pubDate>
            <atom:updated>2019-01-14T11:00:41.926Z</atom:updated>
            <content:encoded><![CDATA[<h3>Powerful Shell for Windows .</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*acm0MLTK2CnSbq-K_qAHyw.jpeg" /></figure><p>Hi friends, Today i want to talk about a powerful shell named <strong>Cmder . </strong>Firstly i want to give a short answer to questions below.I hope my thoughs will be helpfull .</p><ol><li><strong>Why we are using shell?</strong></li><li><strong>Why we need a powerful shell?</strong></li></ol><p>If you are a linux user probably u have experience with the terminal . Terminal gives us an oppatunity for doing commands more faster and easyl . I think a good programmer must comfortably work with terminal . If you have a bit experience with any modern framework such <strong>Laravel,Django or Ruby on Rails </strong>then i think you have at least minimal experience with working terminal <strong>(Remember creating any migration or running server via terminal)</strong> .</p><p>Secondly why we need to use <strong>Cmder</strong>? — like a powerful shell? If you are a user of windows and u are using the default shell of windows from cmd you know it has limitation working like a linux user for example if you want to use any linux command with default windows shell it will not be execute .In a short answer if you want to use linux commands on windows <strong>Cmder</strong> is a good choice for you .</p><p>We can try some linux commands on windows default shell .</p><ol><li>Grep command with a default windows shell</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*2WkHw_xdXI3c-cMQbV1Flw.png" /></figure><p>We see we can’t using a usefull linux command grep.</p><p>2.<strong>Cat </strong>command with default windows shell</p><p>We can try again another usefull linux command <strong>cat</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*tczn4Wbxzi1JdPQu7SCmwQ.png" /></figure><p>So we are again unsuccessfull .</p><p>What is the oppatunity of <strong>Cmder</strong>?</p><p>We can try again grep and cat commands with <strong>Cmder</strong> on a windows machine .</p><p>Look at :</p><p>1.Greap command with <strong>Cmder</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*5RSVQZfG-mnsDz7NzSor7w.png" /></figure><p>It works! Great!</p><p>Now we run <strong>cat</strong> with Cmder.</p><p>2. <strong>Cat</strong> command with Cmder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*bhgT-E2d4RQMzkjTKtvtWg.png" /></figure><p>It works! As cat command function it returned us content of 1.txt file .</p><p>So how can we use <strong>Cmder</strong>? It is so easy!.</p><p>If you are using <strong>Chocolaty </strong>as a package manager<strong> </strong>you can download Cmder via with running :</p><blockquote>choco install cmder -y</blockquote><p>Otherwise you can get it from <a href="http://cmder.net/">its site</a> easly .</p><p>As a result Cmder is a great shell for me . As a developer i suggest you can practice with linux commands in the some points the commands is a life saver. Good luck.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39d74e87c3d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>