cakephp controller not addressed

Wenn es ein Controller namens „xyz“ gibt und gleichzeitig einen Ordner „xyz“ unter „webroot“ , dann wird nicht auf den Controller geroutet, sondern auf den Ordner

If there is a controller named „xyz“ and at the same time a folder „xyz“ under webroot, then the controller is not addressed.

cakephp 3.7

cakephp simple 404 redirect

Simple cakePHP 404 redirect with correct header

public function view($id=null,$slug=null) {
if(!$this->Model->exists($id){
    header('HTTP/1.0 404 Not Found'); //only PHP, no Cake $this->response->header(HTTP/1.0 404 Not Found');
    $this->render('/Model/notfound');
    $this->response->send();
}
$options = array('conditions' => array('Model.' . $this->Model->primaryKey => $id));
$this->set('job', $this->Model->find('first', $options));
}

set Correct 404 Status

cakephp mail versand gmail xampp

Um eine eMail von einem Xampp System mit cakephp 3 und gmail zu verschicken folgende Einstellung benutzen

'gmail' => [
            'host' => 'ssl://smtp.gmail.com',
            'port' => 465,
            'username' => 'username',
            'password' => '****',
            'timeout' => 60,
            'className' => 'Smtp',
            'tls' => false,
            'log' => true,
            'context' => [
                'ssl' => [
                    'verify_peer' => false,
                    'verify_peer_name' => false,
                    'allow_self_signed' => true
                ]
            ]
        ],

Im gmail Konto muss zusätzlich „Weniger sichere Apps zulassen“ auf „an“ stehen

cakePHP inline Attachment

eMail mit Inline Anhang versenden (cakePHP 2.2.4)

public function sentMailTo() {

App::uses('CakeEmail', 'Network/Email');

//config email in /app/Config/email.php

$email = new CakeEmail('smtp', 'templated');
$email->attachments(array(
            'image.jpg' => array(
                'file' => WWW_ROOT . '/img/image.jpg',
                'mimetype' => 'image/jpg',
                'contentId' => 'cid:part111' //src="cid:part111"
            )
        ));

        $email->viewVars(array(
            'vars' => $vars,
        ));

        $email->emailFormat('html');
        $email->subject('subject');
        $email->to($to);
        $email->template($template);
        $email->emailFormat('html');
        $email->from($from);
        try {
            $email->send();
        } catch (Exception $e) {
            trigger_error("ERROR in Controller::function sendMailTo: couldn't send mail to: $to}.");
            return false;
        }
}