<?php use Main\Article\Article; use Main\JSONwriter\JSONwriter; use Main\XMLWriter\XMLWriter; use Main\Writer\Writer; use Main\Factory\Factory; require_once "vendor/autoload.php"; $articole = new Article('Ion', 'Livu R.', '10/12/1867', 'roman'); try { $writer = Factory::getWriter(); } catch (\Exception $e) { $writer = new XMLWriter(); }
use Main\Article\Article; use Main\XMLWriter\XMLWriter; use Main\JSONWriter\JSONWriter; use Main\Factory\Factory; require './vendor/autoload.php'; /* require 'lib/article.php'; require 'lib/jsonwriter.php'; require 'lib/writer.php'; require 'lib/xmlwriter.php'; */ $x = new Article('Ilie in vie', 'Ilie', 'unknown', 'special'); //cu factory try { $writerTemplate = Factory::getWriter(); } catch (\Exception $ex) { echo $ex->getMessage(); $writerTemplate = new XMLWriter(); } var_dump($writerTemplate); $data = $x->writeThis($writerTemplate); var_dump($data); //fara factory /* $asXml = new XMLWriter(); $asJson = new JSONWriter(); $data = $x->writeThis($asXml); $data2 = $x->writeThis($asJson);