Skip to main content

Posts

Showing posts from March, 2017

Infinite scroll using laravel pagination and jquery

infinite scroll with laravel pagination and jquery Loading the content dynamically at the end of the page when user reaches the end of the page. It is quite easy to implement. So exactly what we want to do is When page loads we want to show some posts. When user scrolls we want to load more posts and append it at the end. Upper to line gives hint what we want to do, show list of some post at   on page loading , when user scrolls fetch other posts via ajax and append it to the list of current post list.  First Implement the code for the Controller In this function when request is simple get request it returns view with 9 latest posts. When it gets an ajax request instead of returning view it returns the compiled html of post and url for the next page in laravel pagination as the json array. When data comes as json array we have to append that rendered output in the view file. So view file will be like this. Initially setting the next-page-url attr

Debug errors of external packages used in laravel project

            Sometime happens that you do everything that  read me file  said and still you get errors like class not found or file not found because you are getting just different version of package. The conman reason is below here. That might be unnoticed if you are beginner. Composer Requirement Mismatch Laravel packages are created by experienced Larvael and php developers. They are best at their work. But when we use that packages we get errors because we don't find out exact requirement for that package or at least for the particular version of the package.  For example requirement of the Laravel version requirement of the php version. There are many packages which have different versions for the different laravel version or for different php version . For example, spatie/laravel-analytics   vinkla/Instagram etc. Example   We will go with example of spatie/laravel-analytics package because it is the package made me aware of th

Creating Virtual Host In Apache

Virtual hosts on Apache Definition Virtual hosting is a method for hosting multiple domain names (with separate handling of each name) on a single server (or pool of servers). This allows one server to share its resources, such as memory and processor cycles, without requiring all services provided to use the same host name. You can read more here Wikipedia - Virtual Host If you have purchase vps than you can use virtual host to host multiple site from the single vps ( or form single droplet if you use digitalocean). Most of vps provider gives linux based os because they are free. I will explain how to create and setup virtual host on digitalocean lamp stack with ubuntu 16.04 Requirements   Ubuntu 16.04 with Apache Install Apache If you don't have already installed then run this commands to install the apache on you os sudo apt-get update sudo apt-get install apache2 Setup folders for site to be hosted Site that are hosted has to be inside the /var/www

Upload image with WYSIWYG editor in laravel

upload image with texteditior Almost every one who start learning any thing in web starts with creating a blogging web site in what ever technology or framework he starts to learn. When we create blog site for learning we just consider the text, but real problem happens when we are building the real blogging site because now we have to consider the images also. Most of the WYSIWYG  editors ( Summernote which is my favourite ) provides the facility to upload the image either through the url or user can upload image from the device. In those two situations  If user uploads image via link then there is no problem as it just put a img tag and set's it's source to the url of image But if user uploads image from its device than img tag stores the image as base64 data. Exact Idea So in the second option the actual image is sent to the server as the base64 encoded data,  That means if you applied summernote to a text area and upload a image than the request going

Debug Laravel App with Clockwork

Laravel is written in the way you can easily track the bug by the error or expection thrown by the laravel. Laravel containas the facility of logging. It logs every thing that happens. It stores this log data in the file name larvel.log. Laravel.log file can be found in the storage/logs folder of your laravel project. Most problem will be solving in laravel if you able to understand the logged data.  Laravel log file One thing that make us to use the external debuggers is run time data. Limitation of laravel's log is that it can not log the run time uninterpreted data, or at least i don't found the way to do so.  In this case we have two choise  1. we use the laravel's log driver and find the clever way to log the data of our interest.  2. We can use external debuggers like clockwork, laravel-debugger etc. The reason i need to find package like this In the project puberstreet.com i had to use the polymorphic relation for likes. I was stuck in

Digitalocean domain name setup

DigitalOcean provides only hosting, it does not provide facility to purchase domain. So you have to get your domain name from the domain registrar. There are many domain registrar like goDaddy and hostingraja etc. You can go with you own preference of domain registrar. Once you have purchase domain you to do some dns settings on both at domain registrar side and on DigitalOcean so your domain name can point to the ipaddress given by digital ocean to your droplet.j In Simple manner you have to do some setup so we can bound your purchased domain name with your droplet ip address. your_domain.com  =>  DigitalOcean _droplet_ip What we have to do is that just we have to change the Name Server of our purhcased domain name to  Name Server   provided by DigitalOcean. If you have purchase domain from godaddy Open You Domains Page Manage Domain godaddy Click Manage DNS In NAMESERVER card  Click on Custom Name Server Change Name Server godaddy

Laravel project hosting on digital ocean with lamp stack

There is nothing tricky to host a laravel project on digital ocean. It is as easy as you are hosting your laravel project on you PC with Linux operating system. If you are using the git then it become more easy to host, maintain and update your project. Digital Ocean + Laravel What you need is, A Digital Oceon account, if you don't have any account just go to this URL "  Digital Ocean Account Create   " . After filling every information you will get 10$ as you trial credit ( and after you spent 25$ it will   give me 25$ so you are buying me 3 months of hosting ) Second you will need a laravel project with git. ( I recommend GitHub for opensource and git-lab for private projects , this are my own opinions )  Now, I am assuming that you have basic knowledge of git command like, push ,pull and clone. If not just checkout for it. If you this two things we are ready to go.