Showing posts with label XAMPP. Show all posts
Showing posts with label XAMPP. Show all posts

Tuesday, April 11, 2017

Sending Email Using Queue (SMTP-GMAIL) in Laravel 5.3 - Part I

In previous post, we have successfully sent an email using Mail::send with some of it's properties and we sent this email using default way or not using background worker or in another word 'queue'. So Right now, we are going to play queue to the email using smtp-gmail :D. mmmm......... Next please follow below instructions
1. Create table for queue and also failed-table too. Queue table is for saving list of some jobs (emails that will be sent) and failed-table is for saving failed list of our emails. For creating those tables, we can use these commands :
php artisan queue:table
php artisan queue:failed-table
So we have two migration files now :
Next, execute migration command:
php artisan migrate
Aaand now we have two tables in our phpmyadmin :
2. Change QUEUE_DRIVER = sync to database on .env file :

3. Create new job :
php artisan make:job {your-job-file-name}

4. Let's create a new route and controller...
5. Actually, we can do this step in step 3, buuut... mmmm.... yaaah... it's okie to seperate it in another step... :D
So... in this step 5, let's complete our handle method :




6. Run php artisan queue:listen
This command is the starting point for our queue job to be executed by laravel.

Friday, February 3, 2017

No data was received to import ... in XAMPP - Windows

Here is the error message :
In this case, I wanted to import an sql file which file size more than 256M, so I got above error. To solve this error just change the 'upload_max_filesize' in php.ini like this :
restart apache server aand go to phpMyadmin again, it should be like this :

Yaaaps... Now we can import sql file again which filesize less than 512M...

Saturday, October 29, 2016

Import and Run Laravel Project in Eclipse PDT




Okie... Next thing we have to do is configuring laravel new server....So go to "Run" menu, choose "Run Configuration" :
Hit "New" to create a new configuration


Just hit "Finish"... okaay... mmmm.mmmmmmm............Next, right-click on welcome.blade.php, then run as webapplication :


Oooops.... We need to run "php artisan serve" from cmd then... :D
 Refresh the page.... aaaand... tadaaa....

Saturday, October 22, 2016

Create Custom Exception in PHP

For creating a new custom exception, we just need to extend the Exception class, as shown below :
To hit this exception, we just need to throw a new exception like this :
Then... The last part :
Result :

Monday, September 5, 2016

Limiting Failed Login Attempts on Laravel 5.3

First... let's create a new fresh laravel 5.3...


Create new database config...I'm using xampp here... then do migration...
Next.. create new auth :

After that.... Let's run our laravel and register a new user....
After registering new user, we will automatically log in... So log out first......Then Login at the top right... After that you will be directed to login page... aaand... try to log in with wrong password or wrong email... For laravel 5.3 maksimum login attempt is 5 with locking period 60 seconds

If we want to change this number to 3 with different lockin period, we just have to change the value on ThrottlesLogins.php as shown below :

Then let's try again....

Sooow... The failed login attemp become 3 with locking period 180 seconds... ehehe... Coool... B-)


That's all... ;)


Demo :

Sunday, August 28, 2016

Playing with PHP Artisan Migration Commands in Laravel 5.3 - Executing Migrations File

In previous post, we have created some migration files so rightnow we can run migration command to add tables to our database. Here's our migrations files :
Then let's run "php artisan migrate" to execute those files....
So... There is only one table created in database but actually we were executing 3 migrations files that we created before. Why is that happened? because 2 files contains no tables... :D only migration_2 files has table and column inside...
Sooo... mmm... let's get back to migration_1 file and put some columns there like this one :
So we added 4 columns, id, myAwesomeColumn, created_at & updated_at from timestamps...So let's run or execute this file again by using "php artisan migrate".. :D
Ooops... We have executed php artisan migrate before, so there is nothing to migrate... So we know that migrate is only work for new migration file. So for the old one, we can use three options, migrate:refresh,reset, and rollback :
We will try all of those commands one by one.. :D
First let's try rollback.....So type php artisan migrate:rollback
Rollback is almost same with reset... It will remove all of our last migration table. So our DB will contain just migration table. Then run "php artisan migrate" again aaand....

So...be carefull when using this rollback command because it will gonna delete all of your data... :D
Next... Let's try migrate:reset...
aaand... waaaw... database is empy again.. :v
So what's the different between rollback and reset...??? mmm... let's find out later.. :)
Then let's see migrate:refresh....
So refresh is using rollback first and then migrate all of the migration file... :)

One thing to note that if have put some data in our database, the refresh will also delete all data in database because it's using rollback... So becarefull with this one too.. :v

So how to add new column without deleting our data...??? This will be covered in the next post...:)
See yaaaa......

Go to the next post....