Web Applications using Laravel with prerequisite intro to PHP, sqlite, blade

Laravel Framework is a very popular and powerful web application framework. It uses the popular PHP language, and encompasses aspects from Node.JS, Vue.JS, Bootstrap and more. Among all the videos I have watched to learn laravel, the Laravel from scratch series seemed the best in my opinion. Now, in order to learn and understand Laravel, it is important to have an understanding of certain prerequisites.

  1. PHP Programming Language
  2. SQL databases – focus on the simple sqlite
  3. The Model-View-Controller (MVC) paradigm with Routes
  4. HTML/CSS/JS and Blade templates

Lets start with these prerequisites first PHP

  • Encapsulate PHP in any HTML document between the tags as shown <?php echo “Hello World”; ?>
  • PHP variables are not declared first. All variables are prefixed with $ . <?php $helloWorld = “Hello World”; print $helloWorld; ?>
  • All statements are terminated with ;
  • Strings are concatenated using the . (dot) operator.
  • Output using echo or print is just written as HTML text. So, if you want a newline, enter an HTML text at the end of the string (such as <BR>) <?php $helloWorld = “Hello World”; print $helloWorld . “<BR>”; ?>
  • Convert strings to “int”, “float” values (for computations etc.) by using functions intval(string), floatval(string) <?php $ival = intval(“43″); $fval = floatval(“55.43″); ?>
  • Comments in php using either # or // or /* .. */ <?php /* This php snippet is to demo the use of comments This is a multiline comment. */ // A Java/C++ style single line comment # A linux script style single line comment ?>
  • String operations in php. strlen(string) —- get length of string strcmp(string1, string2) —- Compare two strings – case sensitive compare strpos(haystack, needle) —- finds position of the first occurrence of a string (needle) inside another string (haystack). Note: String positions start at 0, and not 1. strstr(haystack, needle) —- finds first needle in haystack and returns string starting with needle strtok(string, tokens) — Tokenize a string, using characters defined in the tokens string. Subsequent calls after the first call only contains the “tokens” argument. strtoupper(string)/strtolower(string) —- Convert strings to upper or lower case substr(string, firstPos, length) —- Returns a substring, starting with “firstPos” and with “length” characters. firstPos starts with 0. trim(string)/ltrim(string)/rtrim(string) —- returns a string with whitespaces removed from both, left or right sides of the string. str_split(string) — returns an array of characters that make the string. explode(separator,string) —- returns an array of strings separated using the “separator” string.
  • Arrays $array = [ "key1" => "value1", "key2" => "value2" ]; $elem_key1 = $array["key1"]; $array = array(“value1″,”value2″,”value3″); $elem_0 = $array[0]; $arr_count = count($array);

Leave a Reply