laravel disqus integration guide plus example 2020

laravel disqus integration guide plus example 2020



Hi, So today we are going to add Disqus in laravel application. So if you have a project ready where you want to add Disqus Commenting System. We can start here.





Open the terminal and go to your project directory.



Commands Shortcuts
cd box — will take you inside of box folder





ls—will display the list of files and folders in current directory



cd .. — Will take you out from the current folder





sudo chmod -R 777 foldername —-This command will provide full permissions to folder



Now I hope you manage to get into your project folder using the terminal. If not leave a comment i will try to help you.





Now its time to install our package. Run below-given command in the terminal.



composer require yajra/laravel-disqus

While command installs the required files. Go to https://disqus.com/ And login/Register. When you are logged in you will be asked this





Click on – I want to install on my site

Next. Provide the website name and other required details.



It will take you to plans screen just choose which plan you want If you want a basic free plan click on subscribe.





In next screen we will declare which framework or CMS we are using, In this case, we are using Laravel so select the option where it says “I don’t see my platform listed, install manually with “



At this moment you will receive a code as given below and the composer command that we ran should be complete by now so place below-given code where ever you want to show the commenting system in Blade.php file.





<div id="disqus_thread"></div>
<script>

/**
*  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
*  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://your-site-short-name.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
                            

IMPORTANT



DO NOT COPY THIS CODE, YOU WILL GET CODE FROM DISQUS WEBSITE USE THAT CODE





Inside above-given code where



var disqus_config = function () {
this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};

PAGE_URL = document.location.href





PAGE_IDENTIFIER = any unique name. For example- current page name.



All done you should see your Disqus commenting system up and running.





In case you are using laravel 5.5 or older version / Or above-given steps did not work for you then you have to follow below-given steps as well.



Yajra\Disqus\DisqusServiceProvider::class
//ADD THIS CODE IN 
//IN LARAVEL PROJECT -> CONFIG/APP/providers
php artisan vendor:publish --tag=disqus
//RUN THIS COMMAND IN TERMINAL
DISQUS_ENABLED=true
DISQUS_USERNAME=your_website_shortname
//ADD ABOVE LINES IN .env FILE

Now all should be working. Hope you like this guide.





https://18.191.183.98/2019/04/09/how-to-setup-laravel-on-macos-xampp-2019/