Yii Framework, AngularJS, Git Notes

Commands

df -h
du -s basic
du -sm basic (display in mb)
ls -lat

Installing Yii via composer

  • Check if composer is installed
    which composer
    // or
    composer --version
    
composer create-project --prefer-dist yiisoft/yii2-app-basic basic

Check the requirements page http://se-cosd.netlab.hof-university.de/~sbokhari/basic/requirements.php

Check the basic webpage http://se-cosd.netlab.hof-university.de/~sbokhari/basic/web/index.php

models, view - two categories:- corporate identity, content

ln -s existingfile newfile source to target create a soft link.

cp main.pp main-01.php
mv main.php main.orig.php
ln -s sourcefile.php destinationfile.php
unlink

Find where you can find the place where you need to change My Application.

config/web.php :- inside the file "name": "Mushy"

web/index - entry script of our application %2f = hexadecimal for /

  • application may consist of different
  • modules may have their own controller.
  • components have no controllers ex- login component,

Models contains functions which contains business logic. Only the data. Controller may render something or nothing. View can have zero or multiple models.

bootstrap is part of asset bundle. widget - window gadget. controller name is linked to the file system in view.

filter says if the rest ai is giving json or xml.

  • Creating an action

Quiz - 1

  1. Characteristics of YII

    • Php framework for rapidly devloping modern web applications
    • Component based PHP framework
    • High performance PHP framework
  2. Yii is best known for,

    • Developing all kinds of web applications using Php
    • Suitable for developing large-scale Php applications
  3. How does Yii compare with other framworks,

    • Like most Php frameworks, it implements the MVC architectural pattern
    • Yii is a full stack framework providing ready to use features: query builder and ActiveRecord for both relational and NoSQL databases
    • High performance is a primary goal of Yii
  4. Versions of Yii,

    • 1.1 : old gen
    • 2.0 : current gen
  5. Yii facts,

    • a pure OPP based framework
    • Yii 2.0 requires PHP 5.4.0 or above, runs best with 7.0

Quiz - 2

  1. Which subdirectory holds the configuration files for the Yii 2 basic application? public_html/basic/config

  2. Which subdirectory holds the controller definitions for the Yii 2 basic application? public_html/basic/controllers

  3. Which subdirectory holds corporate identity view files for the Yii 2 basic applications, views/layouts

  4. file view/layout/main.php holds the corporate identity for Yii 2 False

  5. file controllers/SiteController.php holds the controller for the startpage of the Yii 2 basic application

  6. File controllers/gamesController.php may hold the controller defn for the games controller of the Yii 2 basic application True

MVC image of the Yii

Application structure link text goes here Each application has an entry script web/index.php which is only Web accessible Php script in the application.

  1. entry script will take an incoming request and creates an application instance to handle it.
  2. The application resoles the request with the helps of its components, and dispatches the request to MVC elements.

MVC Request lifecycle

How does an application handle an incoming request?

  1. A User - makes a request to the entry script web/index.php
  2. entry script loads the application configuration and creates an application instance to handle the request.
  3. application resolves the requested route with the help request application component.
  4. application creates a controller instance to handle the request

    request lifecycle

  5. controller creates an action instance and performs the filters for the action

  6. If any filter fails, the action is cancelled.
  7. If all filters pass, the action is executed.
  8. The action loads some data models from a db
  9. action renders a view, providing it with data models
  10. Rendered result is returned to the response application component.
  11. Response component sends the rendered result to the user's browser.

GIT Notes

  1. git commit --amend --rest-author = amending a commit

  2. git log --format=fuller

  3. git log --format=raw Two kinds of commands introduced by Linus travold A. Porcelain commands, B. Plumbing commands.

  4. git blob is the fundamental data unit in Git ecosystem. They are merely binary files. Everything is compressed & transformed into a blob before saving into a git repo.

  5. Git calculates the hash on the content of the file, and not in the file itself.

  6. git log --oneline gives us a compact history data git log --oneline --graph --decorate

  7. Every commit in git is a snapshot of the entire repository.

  8. git checkout - asking git to move me to the branch I was before switching.

    Ref : Git Essentials by Ferdinando Santacroce Second Edition (2017) Summary

Angular Notes

  • AngularJS is a structural framework for dynamic Single Page Web application.
  • Use HTML as a templating language and
  • AngularJS and Angular are incompatible.
  • It is a framework for,

    • client side model view controller (MVC) architecture.
    • model view view model (MVVM) architecture.
  • AngularJS paradigms,

    1. Declarative programming - user interfaces,
    2. Imperative programming - business logic,
    3. Two way data binding
    4. Automatic synchronization of models and views
    5. Avoid explicit DOM manipulation - improve testability, performance.
  • AngularJS Design goals,

    1. Decouple DOM manipulation from application logic.
    2. Decouple client side of an app from server side.
    3. Provide a structure - designing, writing business logic, testing.
  • AngularJS Implementation,

    1. MVC pattern - to separate presentation, data and logic components,
    2. Dependency injection -

      technique where an object supplies the dependencies of another object. Dependency is an object the can be used (as a service) Injection is the passing of the dependency to a dependent object(a client). The service is made part of the client's state. Passing the service to the client, rather than allowing a client to build or find the service is the fundamental requirement of the DI.

    3. Traditional server side services such a view-dependent controller are brought to client-side web applications.
    4. Reduces the burden of the server.

Keywords

  1. Modules - represent the components used in my application, by using modules its easier to reuse code in other applications or other parts of your website.
  2. Directives - extends HTML tags and attributes, easy to bind data to html elements,
  3. Scope - use JS objects to represent a set data, can be data generated on the web server, database, or web service or client side using regular angularjs code.
  4. Expressions - directly linked with Scope ( just refer it as data), page is going to be updated dynamically as the data changes. Data binding.
  5. Services - for performing common tasks such as ajax techniques etc,

Directives

  • ng-app :- directive tells AngularJS that the

    element is the owner of the angular application. <div ng-app="">

  • ng-model :- directive binds the value of HTML control fields (input, select, textarea) to application data. <input type="text" ng-model="firstname">

  • ng-bind :- binds application data to innerHTML view. Binds content of

    element to application variable name. <p ng-bind="name"></p>