$zip = new ZipArchive();
if ($zip->open($file, ZipArchive::CREATE) !== TRUE) {
throw new \Exception('Cannot create a zip file');
}
foreach($files as $file){
$zip->addFile($file[file_name], $file[local_name]);
}
$zip->close();
unlink
, чтобы удалить временный zip."autoload": {
"psr-4": {
"Myks92\\User\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Myks92\\User\\Tests\\": "tests/"
}
},
class Controller
{
private $repo;
pulic function __construct(MissionRepository $repo)
{
$this->repo = $repo;
}
pulic function excuteMission($id)
{
$mission = $this->repo->find($id);
$mission->next();
$mission->save();
}
}
class Mission
{
private $progress;
public function next(): void
{
$progress = $this->progress + 10;
if($progress > 100) {
throw new DomainExeption('Миссия не может быть выполнена.')
}
if($progress = 100) {
throw new DomainExeption('Миссия уже выполнена.')
}
}
}
class Database {
private $mysqli;
public function __construct(){
$dsn = "mysql:host=localhost;dbname=banan165_database";
$this->mysqli = new PDO($dsn, "root", "");
}
public function query($sql){
return $this->mysqli->query($sql);
}
}
$db = new Database();
$db->query("INSERT INTO categories(name) VALUES('PDO')");
date('d.m', strtotime('2019-09-11'))
(new DateTimeImmutable('2019-09-11'))->format('d.m')