To know which version of PHP you system is using by default, open terminal, run “which php” without the quotes.

If what you get IS NOT “/Applications/XAMPP/xamppfiles/bin/php”, here’s how to correct it

Create a file called .bash_profile on your home directory (if you don’t have this file already) from terminal, to do this run the following commands one line at a time

Cd /

Sudo nano .bash_profile

Then add this to the file:

export XAMPP_HOME=/Applications/XAMPP
export PATH=${XAMPP_HOME}/bin:${PATH}
export PATH

Then hold “Control X” when prompted to save type y and press enter
Then quit and relaunch Terminal.app.
To confirm if this has worked, run “which php” from terminal without the quotes, you should get this “/Applications/XAMPP/xamppfiles/bin/php”

Next step is to install composer, to do this, navigate to your XAMPP public folder from terminal (htdocs), to do this, type

cd /Applications/XAMPP/htdocs

To download and install composer type
“curl -s http://getcomposer.org/installer | php”
and hit enter without the quotes, composer will download and install

Now you can install laravel, to do this type the following without the quotes and hit enter

composer create-project laravel/laravel --prefer-dist

This will download and install the latest version of laravel on your htdocs folder

if you visit http://localhost/laravel/public you’ll find a blank screen, don’t panic, its just a folder permission issue. To fix this, in terminal type the following and hit enter

Cd /Applications/XAMPP/htdocs/laravel

After that, type the following ad hit enter

sudo chmod -R 7777 storage

try opening http://localhost/laravel/public again, you should now see the default laravel page.

Serve Artisan:

serve Artisan command:

php artisan serve

By default the HTTP-server will listen to port 8000. However if that port is already in use or you wish to serve multiple applications this way, you might want to specify what port to use. Just add the –port argument:

php artisan serve --port=8080

configure a database connection.

You may configure all of your database connections from the app/config/database.php file. By default, Laravel is configured to use MySQL, and you will need to supply connection credentials within the database configuration file. If you wish, you may change the driver option to sqlite and it will use the SQLite database included in the app/database directory.

Next, to create the migration, we’ll use the Artisan CLI. From the root of your project, run the following from your terminal:

php artisan migrate:make create_users_table

Next, find the generated migration file in the app/database/migrations folder. This file contains a class with two methods: up and down. In the up method, you should make the desired changes to your database tables, and in the down method you simply reverse them.

Let’s define a migration that looks like this:

public function up()
{
    Schema::create('users', function($table)
    {
        $table->increments('id');
        $table->string('email')->unique();
        $table->string('name');
        $table->timestamps();
    });
}

public function down()
{
    Schema::drop('users');
}

Next, we can run our migrations from our terminal using the migrate command. Simply execute this command from the root of your project:

php artisan migrate

If you wish to rollback a migration, you may issue the migrate:rollback command. Now that we have a database table, let’s start pulling some data!

Advertisements