Steps to set up a new Laravel app, initialize a git repo, push to Github

This is a list of steps to:


Setup a new Laravel app
Initialize a local repository using git
Create a new remote repository using GitHub
Change README.rdoc

Assumptions:


PHP is installed
Composer is installed
Git is installed
Github account is established
Setup a new Laravel app

Navigate to the directory in which you want the new app created using 'change directory' (cd).

Use the 'make directory' (mkdir) command if you want to create a new directory, such as laravel_projects (Note: Laravel will automatically create a directory for all your app files)

  $ cd <correct_directory>  

Create a new app. It's good practice to append your new app name with 'blog' so that it will not be confused with any classes you create later.

Installing Laravel


Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine.
Via Laravel Installer

First, download the Laravel installer using Composer:
composer global require "laravel/installer"
Make sure to place composer's system-wide vendor bin directory in your $PATH so the laravel executable can be located by your system. This directory exists in different locations based on your operating system; however, some common locations include:
·     MacOS: $HOME/.composer/vendor/bin
·     GNU / Linux Distributions: $HOME/.config/composer/vendor/bin
Once installed, the laravel new command will create a fresh Laravel installation in the directory you specify. For instance, laravel new blog will create a directory named blog containing a fresh Laravel installation with all of Laravel's dependencies already installed:
laravel new blog
Via Composer Create-Project
Alternatively, you may also install Laravel by issuing the Composer create-project command in your terminal:
composer create-project --prefer-dist laravel/laravel blog

Navigate to the newly created directory using 'cd'

  $ cd <new_app>

Initialize a git repository


Initialize a new git repository locally
(This initializes a repository in the current working directory, so ensure you are in the correct one.)

  $ git init  
Add everything in the current directory to the repository

  $ git add .  
OPTIONAL - Check git status to show you what is currently in the 'staging area'

  $ git status
Commit all the changes in the 'staging area' to the LOCAL git repository and add a comment

  $ git commit -m "Initial commit"
OPTIONAL - Check the log to show a list of commit messages

  $ git log                                              
Create a new GitHub repository and set to master branch

Create a new GitHub repository

  # Log in to GitHub

  # Select 'New repository' or navigate to https://github.com/new

  # Add a Repository name that matches your app name (<new_app>)

  # Deselect 'Initialize this repository with a README.
Tell git to add Github as the origin of the 'master' branch

  $ git remote add origin git@github.com:<username>/<new_app>.git          
Push the local repository up to Github (the remote repository)

  $ git push -u origin master
Change README.rdoc, commit and push the change

Open README.rdoc in TextMate

  $ mate README.rdoc     
                                     
  # Replace default info with info relevant to your app
Commit all (-a) modifications with a comment (-m) about what was changed
[Use 'git add' first if new files were created]

  $ git push                                     
Push locally committed changes to Github
[Can skip 'origin master' b/c one push was done above]


  $ git commit -a -m "Improve the README file"  

Comments

Popular posts from this blog

Laravel 5 Chart example using Charts Package

Laravel Stats Tracker

PHPMyBackup - A PHP MySQL differential backup script