why Base table : 1146 ‘database.tables’ doesn’t exist laravel 5

This is the very common error occurs for beginners.

Error is like, the table is not exist which the user wants to use”.

As per the laravel documentation, it is good to make the table name in plurals.

For example you have given the table name is “user” .

But laravel is searching for the table name as “users”, because by the documentation name should be “users” ,that’s why  error is occuring.
So for resolving this we have to define the exact table name in the model as we have given the table name:-

For Example – We have a shayari model class looking like this

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class shayari extends Model
{
protected $fillable = [‘cat_id’,’sub_cat_id’,’image’,’status’];
}

In above model class we have given statically our exact table name, which we wants to use.

Than above model class will looking like this after the updation.

class shayari extends Model
{
protected $table = ‘shayari ‘;
protected $fillable = [‘cat_id’,’sub_cat_id’,’image’,’status’];
}

As we have the shayari model.In which we can clearly see that we have mentioned the exact table name.

So laravel will not looking for a plural name of a table and it will not throw  “table does not exist error”.

Check it also

check for the documentation

How to Set the cron for Codeigniter in ubuntu ec2-instances

 “set the cron for codeigniter in Ubuntu ec2-instance” It is very easy to do this .

lets say you domain is www.abc.com and your controller is “Category” and Method is “test” on which you wants to apply a cronjob :-

If you simply hit that function on browser than

the url will be :-http://www.abc.com/index.php/category/test

or

http://www.abc.com/category/test

Just login into your instances by putty and follow below steps :-

1-type crontab -e // for edit the cron or creating the new one

2-choose a editor to edit the cron

set the time as per your need to hit the cron by
* * * * * and the above url

5 stars are explained below:
1st star:      Minute (ranges from 0-59)
2nd star:     Hour  (ranges from 0-23)
3rd star:      Day (ranges from 1-31)
4th star:      Month(ranges from 1-12)
5th star:      Day-of-week (0-7. 0 & 7 is Sun. 1-Mon, 2-Tue,3-Wed,4-Thur … etc)

let say you want hit the corn at 11:15 Am daily once in a day than cron path will be

15 11 * * * curl –silent http://www.abc.com/index.php/category/test

or

15 11 * * * curl –silent http://www.abc.com/category/test

Type the above url in cron editor and for save CTRL+X and Shift + Y than enter to save the cron .

For checking the cron is properly  set or not ,

we can check with “crontab -l” command.

which is used for listing  all the existing crons.

 

 

Check it also

Chech the ubuntu Docs

How to install LAMP on ec2-instances

Here we are going to explain the Steps of installing the LAMP on ec2-instance .

  • For installing the LAMP first of all you should have the AWS account.
  • AWS offered the basic free tier for 1 year with limited space.
  • Just Go to https://aws.amazon.com/ and Click on “Sign in to the Console
  • If you have already registered user then fill the credential on below screen

LOG IN

SIGN UP

  • If you don’t have the account then create a new here signup

Steps for Configuring the instance from AWS Dashboard

  • after login checkout the dashboard :-
  • login

Here we have ec2 instance Tab ,if you don’t found that on the welcome screen

than go to services->EC2 . Click on EC2 .

Then click on free tier only

free

  • Step 1: Choose an Amazon Machine Image (AMI)

Then select the Ubuntu 14.04 Instance for installing the LAMP

ubuntuStep 2: Choose an Instance Type – here you can choose free tier instances

type

Step – 3 – Configure Instance Details:-

details

Step – 4 Add Storage – Nothing to do ,you will get 30Gb free storage in free tier ,

storage

Click on Add Tags – nothing is required in this section

  • Click on Configure Security Groups

tags

 

 

  • click on Add Rule to access the instance from browser.

rule

  • Now click on Review And Launch .

review

  • Click on Launch

launch

if already have a key-pair than you can use that but i recommend to create a new one:-

1- create a new key pair from first drop down

2-key pair name (any thing you like)

3- click on Download Key Pair (keep the file safely)

4- click on Launch Instance

keypair

 

popup

popup2

Click on View Launches

view

Here you can see info  like instance  running state,its IP address and so on.

now  we will install the LAMP on instance.

Download Useful Software for connecting to the command line

download the puttygen.exe

puttygen

  • click on load and open the .pem file generated by the key pair.
  • click on generate and the .ppk file will  be downloaded which is required in ssh login
  • Click on Save Private key
  • Click ‘Yes’ on popup and name to a new .ppk file and file will be downloaded.
  • Download the putty.exe and open

fill

1- Host Name –  IP address from AWS dashboard

2-In left side bar click on SSH than auth than browse the .ppk file which you have recently generated and click on open

3-you will get the putty security alert

security

click on yes next it will say login as : ubuntu (which is username)

Click yes on putty security alert and than you will be in command prompt of the instances

Here we will run commands and install LAMP  ,

Note :- in below command there will be some Y/N option will be come, choose Y to continue the operation.

LAMP Installations Command 

  • sudo su
  • apt-get update
  • apt-get install apache2
  • apt-get install mysql-server php5-mysql

it will ask for choose the server ,select apache / apache2 and ask for create  a new database password make it as you want .

  • apt-get install php5 libapache2-mod-php5 php5-mcrypt
  • service apache2 restart
  • a2enmode rewrite
  • service apache2 restart
  • apt-get install curl
  • service apache2 restart
  • cd var/www/html/
  • apt-get install php5 libapache2-mod-php5 php5-mcrypt
  • apt-get install phpmyadmin apache2-utils

Check for instance : – http://your IP Adrress /

Note :- if  phpmyadmin not worked tham

1-vim /etc/apache2/apache2.conf /// add the line to the end of the file:

2- Include /etc/phpmyadmin/apache.conf
3-/etc/init.d/apache2 restart

Congratulation you have successfully installed the LAMP on your ec2 ubuntu instance.

Run crone on AWS