Eroare
  • XML Parsing Error at 1:445. Error 4: not well-formed (invalid token)

Articole noi

Viata sanatoasa


- Dr. Virgiliu Stroescu: Cum sa mancam sanatos, cum sa invatam sa mancam sanatos. Cum? Cat? Cand? De ce asa si de ce nu altfel? Cat de usor, de ieftin este sa mancam sanatos? Afli despre controlul greutatii si mentinere mancand sanatos fara infometare (sau pentru cei slabi, ectomorfii cum sa se "ingrase" sanatos) - Emisiuni TV.
80-90% din bolile oamenilor sunt declansate de alimentatia nesanatoasa, de mancarea nesanatoasa pe care o mananca zilnic, de hidratarea insuficienta (trebuie minim 6-8 pahare de apa/zi), lipsei de miscare (fara activitati fizice sau sport, etc. - minim 30-60 minute/zi), iar apoi din cauza somnului insuficient (sau prea mult), stresului, poluarii, etc.
Dr. Virgiliu Stroescu - dr. Endocrinolog si Nutritionist   
 - Aditivii alimentari periculosi pentru sanatate! - Lista aditivilor alimentari periculosi. Otrava zilnica din mancare. Ce nu stiai despre aditivii alimentari (E-uri).
Carti despre Stil de Viata Sanatos, Wellness, sanatate, alimentatie, nutritie sanatoasa si retete, etc.:
- Studiul China. Cel mai complet studiu asupra nutritiei

- Dr. Emil Radulescu

- Elena Pridie

- Dr. Ovidiu Bojor

- Dr. Gheorghe Mencinicopschi

Carti utile:

- Cartea de bucate a Centrului Lifestyle Herghelia + DVD

- Tablete de stil de viata - Sanatatea nu este totul, dar fara sanatate, totul este nimic.

SanatateSiViata.ro: Pentru un Stil de Viata Sanatos si o Viata Fericita
SanatateSiViata.ro: Pentru un Stil de Viata Sanatos si o Viata Fericita

Mai multe detalii despre viata sanatoasa, alimentatie, nutritie sanatoasa, wellness, dar si emisiuni TV le gasiti aici


Companii care produc  produse 
pe baza de plante, naturale:

HOFIGAL - HOmeopatie, FItoterapie, GALenice
HOFIGAL - HOmeopatie, FItoterapie, GALenice (Ghid Terapeutic - Lista afectiuni, boli si produse naturale de prevenire, vindecare, ameliorare recomandate de Hofigal)

Interviu cu Stefan Manea, directorul general HOFIGAL


Alte companii:

- Fares - Laboratoarele Fares Bio Vital - Ceaiuri, Tincturi, Uleiuri, Siropuri naturale, Creme, Capsule
- Dacia Plant - Tincturi, Comprimate, Ceaiuri si Remedii Naturiste


Producatori si Magazine de produse Naturale, Bio, Eco: 
sanovita-logo-sigla-3 
SanoVita - produse Vegetariene ca alternativa pentru cei care doresc sa reduca sau sa renunte la consumul de carne in vederea dobandirii unei sanatati mai bune.

Naturalia - Magazin cu produse naturale, Bio, Eco
Naturalia - Magazin cu produse naturale, Bio, Eco


ecolife-ro-logo

Aparente inselatoare


INITIUM, o otrava aprobata oficial pentru agricultura romaneasca

Ce sunt adjuvantii folositi pentru vaccinuri? Despre cum sunt facute vaccinurile si cat de periculoase sunt acestea. Adjuvantii din vaccinuri: saruri de aluminiu, sqalena, mercur pentru conservarea vaccinurilor etc.

Marea escrocherie a incalzirii globale - Un documentar absolut fenomenal - The Great Global Warming Swindle

The Obama Deception - Inselaciunea Obama

The Obama Deception and The Bilderberg Group, Bilderberg conference, or Bilderberg Club is an annual, unofficial, invitation-only conference of around 130 guests, most of whom are persons of influence in the fields of politics, banking, business, the military, and media. Each conference is held under intense security and secrecy.- Video
Dar si Hal Lindsey vorbeste despre Clubul Bilderberg sau Grupul Bilderberg si planul pentru depopulare - Miliardarii decid cine traieste si cine moare !
Clubul secret al miliardarilor.


Earthlings - Pamantenii - Film Documentar

Earthlings, in traducere Pamantenii, este un documentar de lung metraj despre cruzimea oamenilor fata de animale, despre dependenta absoluta a umanitatii fata de animale (pentru companie, mancare, imbracaminte, sport si divertisment, sau pentru cercetare stiintifica si medicala), dar ilustreaza in acelasi timp totala nostra lipsa de respect pentru asa zisii "furnizori ne-umani". Filmul este povestit de catre Joaquin Phoenix (GLADIATORUL), nominalizat la premiile Oscar, iar coloana sonora este asigurata de catre Moby, artistul castigator al discului de platina.

Studiind in profunzime pet shopurile, crescatoriile de pui si adaposturile de animale, precum si fermele – uzine, afacerile cu piele si blana, industriile sportului si distractiei, si in final profesiile medicale si stiintifice, EARTHLINGS foloseste camere ascunse si filmari care nu au fost niciodata aratate pana acum pentru a realiza cronicile de zi cu zi ale unora dintre cele mai mari industrii din lume, care se bazeaza in intregime pe animale pentru a obtine profit. Puternic, provocator si dand nastere la intebari, EARTHLINGS este de departe cel mai cuprinzator documentar produs vreodata despre corelatia dintre natura, animale, si interesele economice umane. Exista multe filme bune despre drepturile animalelor, dar acesta transcede scenariul. EARTHLINGS necesita sa fie vazut.

Filmul documentar Earthlings - Pamantenii se poate vedea si aici.

Vizitatori online

Avem 4 vizitatori online
Prima pagina IT & C Web Development Zend Framework tips and tricks - PHP Framework - PHP MVC
Zend Framework tips and tricks - PHP Framework - PHP MVC Imprimare
Scris de Administrator   
Vineri, 11 Iunie 2010 13:33
Vizualizări: 368

Zend Framework tips and tricks

zend-framework-logoIt’s always good to use great tools, but you need to make sure that you use them correctly, not just trying to code “just for it to work”. For this reason I decided to write down my usual list of things I mention when taking over some legacy project or just consulting someone how to start.

Most of the outlined problems and solutions are focused on testability, maintainability and other good code practices. If you are not familiar with them, I recommend read about them ASAP as there is big chance that you are doing those things described in this post and don’t even realize how wrong they are. Believe me, you will soon find yourself a way better developer.

Separate logic


This one is the most obvious one, but trust me, I have found cases of it in every single project I have worked before (more than 10 with Zend Framework in a past half year and counting). If it’s controller, don’t do business logic, if it’s model don’t base behavior on POST parameters etc. Same applies to forms, bootstrap, views, various helpers and many more other components – logic should be separate and have its place.

Move all logic from controller to a model or service. Use forms only to handle validation and filtering, not to actually process data and persist it in any fashion. Hide session and authentication handling in one place and provide API for other algorithms. I can go on, but I hope it’s starting to get pretty clear, or at least it will eventually when you start testing your code: when you need to setup frontController, request, cookie and mail server just to test a form you realize that something is really wrong.

Globals


If you haven’t seen this video, please do it immediately – you won’t regret it. Global state makes testing problematic and is completely opposite to what OOP proposes. This applies for use of $_SERVER, $_SESSION etc. values and all of them are accessible via request object (look atZend_Controller_Request_Http) methods or separate classes, like Zend_Session.

Yet again I’m going to mention testability, because that’s something you always need to keep in mind. Test should not modify global variables, but rather inject mocked request/other objects which just return expected values (like client IP), because Zend Framework does pretty good job abstracting access to all global variables.

Use form values, not request


This one is both security and ease of coding issue, let’s look at this code sample:

$form = new Form();
 
if ($this->_request->isPost()) {
 
if ($form->isValid($this->_request->getPost())
{
$model = new Model($this->_request->getPost());
$model->save();
}
else
{
$form->populate($this->_request->getPost());
}
}

After form is validated (and hence values are filtered), raw values from request are still used from $this->_request->getPost(). Not only do you lose Zend_Formfunctions like ignored elements (for submit buttons for example) but also none of the filters are applied (which you use, yes?). Also I can pass pretty much anything I want and model needs to do way more validation. Hence $form->getValues() should always be used as it returns form data with respect to all defined rules and filters.

Form populate() method is also very overused. This method is designed to set default values for a form, from for example GB entry (when editing something) apart from that, you simply don’t need to use it as method isValid() sets values for all elements, so there is no need to apply default values too.

Do not rely or use exit()/die()


One of the first things I do is remove all these exit() calls and handle such cases with exceptions or return statements. There is only very very limited amount of situations where you actually need to use one of those functions. Just for example, imagine this controller action code:

if (!$this->userHasPermissions())
{
$this->_redirect('/');
}
 
$form = new Form_Add();
 
if (//submit form)
{
// save with $form->getValues();
$this->_redirect('/index');
exit();
}
 
// do something else

First problem – thinking that $this->_redirect() will call exit() and hence nothing else will be executed. Even though this is true by default, this should be avoided in all cases. Not only it makes all post* events to not be fired, but also it makes testing impossible or incorrect. Zend_Test disables use of exit() in controller helpers, so in this case while testing you cannot test permissions checking as in all cases it will still execute later code. To fix this just add returnin front of redirect (return $this->_redirect(‘/’)) and you are safe.

Furthermore, second exit() is completely useless and makes code even more untestable. Again you can just use return to cancel later code (view will not be rendered as viewRenderer helper checks for redirection header and does nothing if detects such). From my experience, after saving entry, there is only some assignments to view in left code so you won’t suffer a lot if you just leave redirect, of course without exit().

Use a framework, not PHP


This can sound wrong at first, but if you use a framework (Zend Framework in this case) don’t start throwing in hacks from 5 year old PHP apps. Like this (controller action):

$object = new Some_Object();
 
$image = $object->generateImage();
 
header ('Content-type: image/jpeg');
echo $image;

I don’t even know where to start… All this logic is incorporated in response object, so you can do things like:

$this->getResponse()->setHeader("Content-type", 'image/jpeg');
$this->getResponse()->setBody($image);

It might seem as same thing, but it’s not. Yet again you can actually test it, you are not working with global state (header() is global state function) and request dispatch process is left working as it should. Controllers do not output any data (hence no echo should be used) they just get request object and return response object, that’s it. In a similar fashion as exit() breaks dispatch process, outputting from controller does that too, so don’t forget to make sure that you preserve this flow.

Some small ones


Application.ini
has a property includePaths, which is used to add additional paths to include path. Even though it works great, I still recommend not to use it because it will add those paths every time you create new application instance (true for 1.9, can change in future). If you try to do some controllers testing, you are probably going to instantiate it before every single test and after some hundreds of tests you will notice that somehow it’s getting slower and slower. That took me a few hours to find, though fix was easy, but still keep that in mind.

If you are using jQuery or any other javascript view helpers, take full power of them. By that I mean use functions like addJavascriptFile()addJavascript(),addStylesheet()addOnload() etc. to add some additional resources and code from views. If you add javascript straight to view everything will still work, but by using view helper container you will have all your code nicely placed in one place and not scattered all other the place.

Conclusion


This is just a small list of problems and issue I have seen in my work – there are way more to look at (you can share some tips too). I hope those will give you some idea how to work with Zend Framework in a clean fashion and you will soon find that your code is starting to look nicer and coding time is decreasing as everything is nicely separated and transparent to other code.



Source: http://dev.juokaz.com/php/zend-framework-tips-and-tricks

Zend Framework 1.8 tutorial 1 MVC basics

 

Adaugă comentariu

Comentariile care contin cuvinte indecente, obscene, rasiste, etc. nu sunt publicate.


Codul de securitate
Actualizează

Sustin - Promovez


Asociatia 'Pro Vita pentru nascuti si nenascuti' - Filiala Bucuresti

Campania de panotaj "Avortul opreste o inima care bate!" a inceput in Bucuresti

ACTUALIZARE 30 martie 2011: Primul panou a fost deja decorat si se afla la intersectia intre Bd. Libertatii si Calea 13 Septembrie, vis-a-vis de Palatul Parlamentului (vezi foto). Locatia a fost aleasa pentru a atrage atentia alesilor nostri. Simultan cu montarea panoului, toti parlamentarii romani in functie au primit o informare cu privire la desfasurarea "Marsului pentru viata" 2011.

In zilele urmatoare vor fi decorate si alte panouri.

Va multumim mult pentru sprijinul acordat si asteptam in continuare donatiile voastre pentru a continua campania!

Campania de panotaj "Avortul opreste o inima care bate!" a inceputDetalii despre campania de panotaj la: www.ProVitaBucuresti.ro

Canal video Pro-Vita:
Pro Vita Bucuresti pe Vimeo 

Cultura Vietii - Blog de promovare a valorilor vietii

Internet mai sigur pentru copii

Alianta Familiilor din Romania

Proiectul "Pentru-Viata" - PentruViataCluj.ro

Ce NU se spune despre: avort, anticonceptionale, contraceptive, sterilet, RU 486 (Mifepristone), avort timpuriu, avort menstrual, avort hormonal, avort medicamentos, Sindromul Post-Avort, bolile cu transmitere sexuala, prezervativ, spermicide, fertilizarea in vitro - FIV, cum se dezvolta copilul nenascut (intre conceptie si nastere), dezvoltare embrionara, fetala, etc. Studii medicale, filme, marturii, etc. - www.AdevarulDespreAvort.ro

"Raspunsul la criza unei sarcini este eliminarea crizei, nu a copilului."

(Jeannie W. French)

Valea Plopului 380 Orphans on Facebook - Voluntari in Romania pentru a ajuta copii orfani (si copii salvati de la avort) din asezamintele de plasament familial Pro-Vita din Valea Plopului si Valea Screzii, Jud. Prahova
 

 

DONEAZA - Ajutorul tau conteaza!

Asociatia Pro-Vita - Filiala Bucuresti a Asociatiei mama din Valea Plopului si Valea Screzii, Jud. Prahova (zona Valenii de Munte circa 110 km de Bucuresti)

Asociatia "Pro-Vita pentru nascuti si nenascuti" - Filiala Bucuresti a Asociatiei mama din Valea Plopului si Valea Screzii, Jud. Prahova (zona Valenii de Munte circa 110 km de Bucuresti) unde sunt si asezamintele de plasament familial Pro-Vita conduse de preotul Nicolae Tanase.


Valea Plopului, Valea Screzii - Ajutor din partea Fundatiei Crestine Parintele Arsenie Boca - Iarna 2010
"Valea Plopului este raspunsul la intrebarea daca va mai exista crestinism in Europa." Dr. Iosif Niculescu, 95 de ani


Fundatia Crestina Parintele Arsenie Boca - FundatiaArsenieBoca.ro 
Tabara de vara de voluntari ASCOR "Impreuna pentru copiii de la Valea Plopului" - Editia III - 12-26 iulie 2010



Centrul Gifted Education

John McCain and Sarah Palin for America

antiprostitutie.ro-fata-nevazuta-a-prostitutiei-legalizate-banner1

Ortodox Media: stiri si inregistrari audio-video ortodoxe

itsy-bitsy-radio-sigla-logo

Citate

" Toata lumea stie ca anumite lucruri sunt irealizabile, pana cand vine cineva care nu stie acest lucru si le realizeaza. "


Albert Einstein

(n. 14 martie 1879, Ulm - d. 18 aprilie 1955, Princeton)


Sa iubim si animalele


Adopta o pisica draguta

Credincios, jucaus, prietenos

Vremea

An error occured during parsing XML data. Please try again.