Luce Digitale

Install Symfon y1.4.20 on WAMP and WIN7 with PEAR

PEAR installation

PEAR is a framework and distribution system for reusable PHP components.

0. Start WAMP

1. Download PEAR at http://pear.php.net/go-pear.phar

The phar extension provides a way to put entire PHP applications into a single file called a “phar” (PHP Archive) for easy distribution and installation.

2. Copy go-pear.phar into C:\wamp64\bin\php\php5.6.25

3. On Win Button type cmd.exe, RMB ‘Run as Administrator’ and navigate to C:\wamp64\bin\php\php5.6.25

4. Input in the command window: php go-pear.phar
– Are you installing a system-wide PEAR or a local copy?: leave default (system:loca) [system]
– Below is suggested file layout… (locazioni proposte per l’installazione): ENTER to go on
– Would you like to later php.ini?: Y (includerà il path per il pear)
– Enter to continue: ENTER

5. C:\wamp64\bin\php\php5.6.25 double click Pear_ENV.reg (aggiunta al registro di sistema)

PEAR is installed

Nota: per vedere il registo di sistema cliccare sul bottone di windows, in cerca programmi e file scrivere ‘regedit’

Environment variables

1. Bottone di Windows> RMB Computer> Proprietà> Impostazioni di sistema avanzate> Avanzate> Variabili d’ambiente> Variabili di sistema> Variabile Path> Modifica…>aggiungere il separatore ; e C:\wamp64\bin\php\php5.6.25

Symfony 1.4

1. On Win Button type cmd.exe, RMB ‘Run as Administrator’ and navigate to C:\wamp64\bin\php\php5.6.25

2. Type the command: pear channel-discover pear.symfony-project.com (aggiunge a PEAR il canale di Symfony)

3. Type the command: pear install symfony/symfony (scarica symfony-1.4.20.tgz)

At the end you will have the message install ok: …

4. Type: C:\wamp64\bin\php\php5.6.25\symfony -V (message: symfony version 1.4.20), l’installazione è verificata
NB: il comando symfony -V è visto da tutte le cartelle perchè il percorso è registrato

Project Creation

0. We want to create a project named ‘jobeet’

1. Create the folder c:\wamp64\www\jobeet

NB: Windows users are advised to run symfony and to setup their new project in a path which contains no spaces

2. Inside \jobeet folder run the command:
cmd.exe -> c:\wamp64\www\jobeet\symfony generate:project jobeet –orm=Propel

Symfony will create the folder structure:

apps/ Hosts all project applications -> al momento è vuota
cache/ The files cached by the framework
config/ The project configuration files
lib/ The project libraries and classes
log/ The framework log files
plugins/ The installed plugins
test/ The unit and functional test files
web/ The web root directory

NB: The generate:project task has also created a symfony shortcut in the project root directory to shorten the number of characters you have to write when running a task.

App Creation

1. Copy C:\wamp64\bin\php\symfony.bat to c:\wamp64\www\jobeet\

2. cmd.exe -> c:\wamp64\www\jobeet\symfony generate:app frontend

Symfony will create the folder structure:

apps/config
apps/i18n
apps/lib -> libraries
apps/modules -> code MVC
apps/templates

3. Set the write permission for jobeet\cache – jobeet\log – chmod 777, permit read,write,execute

RMB sulla cartella cache> Proprietà> Condivisione> Condivisione avanzata> Condividi la cartella> Autorizzazioni> Consenti> attivare Controllo completo, Modifia, Lettura

RMB sulla cartella log> Proprietà> Condivisione> Condivisione avanzata> Condividi la cartella> Autorizzazioni> Consenti> attivare Controllo completo, Modifia, Lettura

4. Set Apache
LMB over WAMP Icon> Apache> httpd.conf

Copy and paste in the end:

# -------------------------------------------------------------------------------
# Project jobeet START

# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080

# This is the configuration for your project
Listen 127.0.0.1:8080

# 127.0.0.1:8080 da browser punta a c:\wamp64\www\jobeet\web
<VirtualHost 127.0.0.1:8080>
  DocumentRoot "c:\wamp64\www\jobeet\web"
  DirectoryIndex index.php
  <Directory "c:\wamp64\www\jobeet\web">
    AllowOverride All
    Allow from All
  </Directory>

  Alias /sf "c:\wamp64\www\jobeet\lib\vendor\symfony\data\web\sf"
  <Directory "c:\wamp64\www\jobeet\lib\vendor\symfony\data\web\sf">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

# Project jobeet END
# -------------------------------------------------------------------------------

NB: The /sf alias gives you access to images and javascript files needed to properly display default symfony pages and the web debug toolbar|Web Debug Toolbar.

LMB over WAMP Icon> Restart All services

5. Open the browser and point it at: 127.0.0.1:8080 or at http://localhost/jobeet/web/index.php

If you do not see images you have to correct the code addet in httpd.conf.

Reference:
http://symfony.blog.gogo.mn/read/entry350425
https://blog.rolandl.fr/59-installer-symfony-1-4-avec-pear
http://symfony.com/legacy
http://symfony.com/legacy/doc

By |PHP, Symfony, Web Design|Commenti disabilitati su Install Symfon y1.4.20 on WAMP and WIN7 with PEAR

Unity Programming – Attributes – Intermediate – CSharp

La dichiarazione di un attributo ci permette di aggiungere dei parametri limite ad una proprietà di una funzione.

Creiamo un Gameobject Cubo ed alleghiamo lo script SpinScript.cs


using UnityEngine;
using System.Collections;

public class SpinScript : MonoBehaviour
{
    [Range(-100, 100)] // lo specifico sopra la variabile, in Inspector apparirà uno slider
    public int speed = 0; // il cubo non ruoterà finchè non modificherò lo slider

    void Update()
    {
        transform.Rotate(new Vector3(0, speed * Time.deltaTime, 0));
    }
}

Selezioniamo il cubo e in Inspector> SpinScript (Script)> Speed spostiamo lo slider

By |CSharp, Unity3D, Video Games Development|Commenti disabilitati su Unity Programming – Attributes – Intermediate – CSharp

Unity Programming – Delegate – Multicasting – Intermediate – CSharp

delegate è la dichiarazione di un tipo delegato.
delegate è un tipo riferimento che può essere utilizzato per incapsulare un metodo.
In poche parole possiamo incapsulare o o più funzioni (multicast) all’interno di un songolo delegate.

Creare un Empty Object ed allegare lo script MulticastScript.cs


using UnityEngine;
using System.Collections;

public class MulticastScript : MonoBehaviour
{
    delegate void MultiDelegate();
    MultiDelegate myMultiDelegate; // creo la variabile contenitore


    void Start()
    {
        myMultiDelegate += PowerUp; // aggiungo il metodo PowerUp()
        myMultiDelegate += TurnRed; // aggiungo il metodo TurnRed()

        if (myMultiDelegate != null) // controllo che non sia nullo
        {
            myMultiDelegate(); // stampa Power UP! Turn to RED
        }

        myMultiDelegate -= PowerUp; // tolgo il metodo PowerUp()
        myMultiDelegate(); // Turn to RED

    }

    void PowerUp()
    {
        print("Power UP!");
    }

    void TurnRed()
    {
        print("Turn to RED");
    }
}

Con delegate possiamo incapsulare una singola funzione con parametri.

Creare un Empty Object ed allegare lo script DelegateScript.cs


using UnityEngine;
using System.Collections;


public class DelegateScript : MonoBehaviour
{
    delegate void MyDelegate(int num); // creo il delegato con una proprietà int
    MyDelegate myDelegate; // notare che i nomi sono uguali


    void Start()
    {
        myDelegate = PrintNum; // assegno al delegato la funzione PrintNum()
        myDelegate(50); // invio a PrintNum(50)

        myDelegate = DoubleNum;
        myDelegate(50);
    }

    void PrintNum(int num)
    {
        print("Print Num: " + num);
    }

    void DoubleNum(int num)
    {
        print("Double Num: " + num * 2);
    }

    // print:
    // 50
    // 100
}

By |CSharp, Gamification, Unity3D, Video Games Development|Commenti disabilitati su Unity Programming – Delegate – Multicasting – Intermediate – CSharp

Unity Programming – Coroutines – Intermediate – CSharp

Ogni Coroutine viene eseguita in completa indipendenza, condividendo le variabili.
Questo ci permette di generare comportamenti comnplessi senza utilizzare Update()

Creare un Empty Object e allegare lo script CoroutinesExample.cs


using UnityEngine;
using System.Collections;

public class CoroutinesExample : MonoBehaviour
{
    public int mynumber = 0;

    void Start()
    {
        StartCoroutine(MyCoroutine());
        StartCoroutine(MyCoroutineTwo());
    }


    IEnumerator MyCoroutine()
    {
        print("MyCoroutine 0 sec");
        print("Mycourotine number " + mynumber);

        yield return new WaitForSeconds(2f);

        print("2 sec");
        mynumber++;

        yield return new WaitForSeconds(4f);

        print("4 sec");
    }

    IEnumerator MyCoroutineTwo()
    {
        print("MyCoroutineTwo 0 sec");
        print("MycourotineTwo number " + mynumber);

        yield return new WaitForSeconds(3f);

        print("3 sec");
        print("MycourotineTwo number " + mynumber);
    }

    // ogni Coroutine viene eseguita in completa indipendenza, condividendo le variabili
    // print:
    // MyCoroutine 0 sec
    // Mycourotine number 0
    // MyCoroutineTwo 0 sec
    // MycourotineTwo number 0
    // 2 sec
    // 3 sec
    // MycourotineTwo number 1
    // 4 sec
}

By |CSharp, Gamification, Unity3D, Video Games Development|Commenti disabilitati su Unity Programming – Coroutines – Intermediate – CSharp

Unity Programming – Lists – Intermediate – CSharp

Classe List rappresenta un elenco fortemente tipizzato di oggetti accessibili tramite indice. Fornisce metodi per la ricerca, l’ordinamento e la modifica degli elenchi.
Questa classe può contenere ogni tipo di variabile, int, string etc…
Possiamo utilizzare List al posto di Array vista la sua maggiore flessibilità.

Creare lo script BadGuy.cs, NON allegarlo a nessun oggetto
Questo script definisce solamente la struttura della lista


using UnityEngine;
using System.Collections;


//This is the class you will be storing
//in the different collections. In order to use
//a collection's Sort() method, this class needs to
//implement the IComparable interface.
public class BadGuy 
{
    public string name; // proprietà
    public int power;

    // metodo costruttore per ricevere l'input dei parametri
    public BadGuy(string newName, int newPower)
    {
        name = newName;
        power = newPower;
    }
}

Creare un Empty Object ed allegare SomeClass.cs


using UnityEngine;
using System.Collections;
using System.Collections.Generic; // per usare la lista

public class SomeClass : MonoBehaviour
{
    void Start()
    {
        // istanzio la lista, notare la sintassi
        List<BadGuy> badguys = new List<BadGuy>();
        // popolo la ista
        // lista Add new costruttore (parametri)
        badguys.Add(new BadGuy("Harvey", 50));
        badguys.Add(new BadGuy("Magneto", 100));
        badguys.Add(new BadGuy("Pip", 5));

        // inserisce all'indice 1
        badguys.Insert(1, new BadGuy("Joker", 200));

        // accedo alla lista con un indice come un array
        int counter = badguys.Count; // conta gli elementi presenti nella lista
        Debug.Log(counter); // print 4

        string enemy = badguys[0].name; // lista[indice].nomeproprietà
        Debug.Log(enemy); // print Harvey
        enemy = badguys[1].name; // lista[indice].nomeproprietà
        Debug.Log(enemy); // print Joker

        badguys.RemoveAt(0); // rimuove a indice 0
        counter = badguys.Count; // conta gli elementi presenti nella lista
        Debug.Log(counter); // print 3

	foreach (BadGuy guy in badguys)
        {
            print(guy.name + " " + guy.power);
        }
        // print Joker 200 Magneto 100 Pip 5

        badguys.Clear(); // cancella tutto il contenuto della lista
        counter = badguys.Count; // conta gli elementi presenti nella lista
        Debug.Log(counter); // print 0
    }
}

By |CSharp, Gamification, Unity3D, Video Games Development|Commenti disabilitati su Unity Programming – Lists – Intermediate – CSharp