+ All Categories
Home > Technology > Seminario team working - 21-1-2015

Seminario team working - 21-1-2015

Date post: 16-Jul-2015
Category:
Upload: alessandro-loffredo
View: 327 times
Download: 0 times
Share this document with a friend
50
Sviluppare in Team Alessandro Loffredo
Transcript
Page 1: Seminario team working - 21-1-2015

Sviluppare in TeamAlessandro Loffredo

Page 2: Seminario team working - 21-1-2015

Sviluppare in Team

• Condivisione codice

• Condivisione ambiente

• Linguaggio PHP

• HTTP debug

• Esempio PHP + IaaS

Page 3: Seminario team working - 21-1-2015

Ambienti di esecuzione

• Sviluppo

• Test

• Produzione

• Opzionali: Staging, Demo..

Page 4: Seminario team working - 21-1-2015

Condivisone del Codice

Page 5: Seminario team working - 21-1-2015

Version Control Systems

• Tracciare la storia del codice sorgente (e non solo)

• Gestire l’accesso concorrente in scrittura

• Mantenere versioni diverse dello stesso codice

Page 6: Seminario team working - 21-1-2015

Version Control Systems

• Centralizzati (CVS, SVN..)

- 2 metodi: “file locking” e “version merging”

- repository centrale (single point of failure)

• Distribuiti (Git, Mercurial, Bazaar..)

- molteplici repository “centrali” (locali)

- veloce (operazioni in locale)

Page 7: Seminario team working - 21-1-2015

Git

• Sviluppato inizialmente da Linus Torvalds per mantenere i sorgenti di Linux

• Ideale per il versionamento di contenuti testuali

• Largamente diffuso (secondo dopo Subversion)

Page 8: Seminario team working - 21-1-2015

Git - Branching e Merging

Page 9: Seminario team working - 21-1-2015

Git - Workflow multipliSubversion-Style Workflow Integration Manager Workflow (GitHub)

Dictator and Lieutenants Workflow

Page 10: Seminario team working - 21-1-2015

Git - Staging Area

Page 11: Seminario team working - 21-1-2015

Git - git init

Page 12: Seminario team working - 21-1-2015

Git - git add

Page 13: Seminario team working - 21-1-2015

Git - git commit

Page 14: Seminario team working - 21-1-2015

Git - git add

Page 15: Seminario team working - 21-1-2015

Git - git remote add

Page 16: Seminario team working - 21-1-2015

Git - git push

Page 17: Seminario team working - 21-1-2015

Git - git pull

Page 18: Seminario team working - 21-1-2015

Git - .gitignore# C project*.o*.so*.a*.out

# Java project*.class*.jar*.war

# Directorybin/

# Editor backups*~

Page 19: Seminario team working - 21-1-2015

Condivisone ambiente di sviluppo

Page 20: Seminario team working - 21-1-2015

Condivisone ambiente di sviluppo

Ossia l’ambiente (gli ambienti) dove verrà eseguito il progetto in fase di sviluppo

• Configurazione hardware

• Sistema operativo

• Software e librerie installate

Page 21: Seminario team working - 21-1-2015
Page 22: Seminario team working - 21-1-2015

• Uno strumento per creare ambienti di sviluppo basati si macchine virtuali

• Studiato con l’obiettivo di creare ambienti simili o identici a quelli dei server in produzione

• Creato da M. Hashimoto

• Supporta VirtualBox e VMWare Fusion

Page 23: Seminario team working - 21-1-2015

Vagrant - Installazione

1.VirtualBox

2.Vagrant installer (Linux, Windows, OSX ecc..)

3.Scaricare una Vagrant box

Page 24: Seminario team working - 21-1-2015

Vagrant - Box

• Un’immagine di una macchina virtuale Vagrant pronta all’uso

• Sono disponibili al download Vagrant Box per molte piattaforme (Linux, Windows, BSD)

Page 25: Seminario team working - 21-1-2015

Vagrant - Comandi

• $ vagrant init #crea un Vagrantfile base

• $ vagrant up #avvia la macchina virtuale (se necessario la crea)

• $ vagrant ssh #accede alla macchina virtuale

• $ vagrant halt #spegne la vm

• $ vagrant destroy #calcella la vm

Page 26: Seminario team working - 21-1-2015

Vagrant - VagrantfileVAGRANTFILE_API_VERSION  =  "2"  BOX_NAME  =  "trusty64"  BOX_URI  =  "https://cloud-­‐images.ubuntu.com/vagrant/trusty/current.box"  

Vagrant.configure(VAGRANTFILE_API_VERSION)  do  |config|  

   config.vm.box  =  BOX_NAME      config.vm.box_url  =  BOX_URI      config.vm.network  :forwarded_port,  host:  8080,  guest:  80      config.vm.synced_folder  ".",  "/vagrant",  type:  "nfs"  

   config.vm.provider  :virtualbox  do  |vb|          vb.customize  ["modifyvm",  :id,  "-­‐-­‐memory",  "512"]      end            config.vm.provision  "puppet"  do  |puppet|          puppet.manifests_path  =  "puppet/manifests"          puppet.module_path  =  "puppet/modules"      end  

end  

Page 27: Seminario team working - 21-1-2015

• Tool per la gestione automatica di infrastrutture

• Gestisce provisioning e configurazione

• Automatizza i task ripetitivi (backup, upgrade..)

Puppet è una (no “la”) soluzione per fare il setup, gestire e aggiornare infrastrutture composte da molteplici server

Page 28: Seminario team working - 21-1-2015

LAMP Stack

Page 29: Seminario team working - 21-1-2015

Puppet

Non serve definire il “come”..

.. ma il “cosa”

Page 30: Seminario team working - 21-1-2015

Puppet - Manifest

Page 31: Seminario team working - 21-1-2015

Puppet - Package

Page 32: Seminario team working - 21-1-2015

Puppet - Class

Page 33: Seminario team working - 21-1-2015

Puppet - Moduli

• In Puppet un modulo è una collezione di risorse (servizi, package..), classi e template.

• Aiutano a distribuire e favoriscono il riuso del codice

• Run out-of-the-box

• GitHub!

Page 34: Seminario team working - 21-1-2015

Ricapitolando

• Usando Vagrant tutti gli sviluppatori hanno a disposizione lo stesso Sistema Operativo dei server in produzione.

• Usando Puppet/Chef viene garantito che il Sistema Operativo sia configurato in modo identico su una vm con Vagrant, una vm in cloud o un server fisico.

Page 35: Seminario team working - 21-1-2015

PHPPersonal Home Page (1994)

PHP: Hypertext Preprocessor (1997)

Page 36: Seminario team working - 21-1-2015
Page 37: Seminario team working - 21-1-2015
Page 38: Seminario team working - 21-1-2015

Richiesta di una pagina html statica

GET index.html

<!DOCTYPE html><html> <head> <title>Title</title></head>

<body> <!-- page content --> </body></html>

Client Side

Server Side

Page 39: Seminario team working - 21-1-2015

Richiesta di una pagina php

GET index.php

<!DOCTYPE html><html> <head> <title>Title</title></head>

<body> <!-- page content --> </body></html>

Client Side

Server Side

Page 40: Seminario team working - 21-1-2015

PHP - In breve

• Un linguaggio interpretato nato per il web

• Permette di costruire pagine web dinamiche

• Consente di interagire con un database

Page 41: Seminario team working - 21-1-2015

PHP - Una pagina<html> <head> <title>PHP Test</title> </head> <body> <?php

echo '<p>Ciao mondo!</p>';$ora = date('H:i');echo '<p>Sono le '.$ora.'</p>';

?> </body></html>

Page 42: Seminario team working - 21-1-2015

PHP - Alcune variabili d’ambiente

• $_SERVER[‘REMOTE_ADDR’]

• $_SERVER['REQUEST_METHOD']

• $_GEThttp://example.com?a=1&b=2&c=d $_GET['a'] == 1 …

• $_POSTContiene le variabili definite nel body della richiesta HTTP

Page 43: Seminario team working - 21-1-2015

HTTP debug

Page 44: Seminario team working - 21-1-2015

cURL

CURL is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.

Page 45: Seminario team working - 21-1-2015

cURL - HTTP GET$ curl -v http://example.com/ * Connected to example.com (93.184.216.34) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.37.1 > Host: example.com > Accept: */* > < HTTP/1.1 200 OK < Accept-Ranges: bytes < Cache-Control: max-age=604800 < Content-Type: text/html < Date: Tue, 20 Jan 2015 09:57:54 GMT < Expires: Tue, 27 Jan 2015 09:57:54 GMT < Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT < Server: ECS (iad/182A) < Content-Length: 1270 < <!doctype html> <html> …

Page 46: Seminario team working - 21-1-2015

cURL - HTTP POST$ curl -v -XPOST -d foo=bar http://example.com/ * Connected to example.com (93.184.216.34) port 80 (#0) > POST / HTTP/1.1 > User-Agent: curl/7.37.1 > Host: example.com > Accept: */* > Content-Length: 7 > Content-Type: application/x-www-form-urlencoded > * upload completely sent off: 7 out of 7 bytes < HTTP/1.1 200 OK < Accept-Ranges: bytes < Cache-Control: max-age=604800 < Content-Type: text/html < Date: Wed, 21 Jan 2015 01:15:04 GMT < Expires: Wed, 28 Jan 2015 01:15:04 GMT < Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT < Server: EOS (lax004/2811) < Content-Length: 1270 < <!doctype html> <html> …

Page 47: Seminario team working - 21-1-2015

Postman (HTTP client)

Page 48: Seminario team working - 21-1-2015

Hacker News news.ycombinator.com

Page 50: Seminario team working - 21-1-2015

Riferimenti• http://git-scm.com/about

• https://try.github.io

• http://git-scm.com/book

• http://docs.vagrantup.com/v2/getting-started/index.html

• http://docs.puppetlabs.com/pe/latest/quick_start_helloworld.html

• https://github.com/himerya/vagrant-puppet-lnmp


Recommended