git ssb

0+

k4ml / belajar-js



Commit 8299689d7c672b368a9d378863049d0b71a98d22

Update pengenalan-composer.md

k4ml committed on 2/6/2015, 9:10:40 AM
Parent: 68201f796962d301580da907fa279d45052455c1

Files changed

_tips/pengenalan-composer.mdchanged
_tips/pengenalan-composer.mdView
@@ -24,4 +24,30 @@
2424 php composer.phar install
2525 Loading composer repositories with package information
2626 Installing dependencies (including require-dev
2727 ```
28+Setelah `composer` selesai download, anda boleh mula menggunakan library tersebut dalam *script* PHP anda dengan hanya menambah baris berikut:-
29+
30+```php
31+<?php
32+require 'vendor/autoload.php';
33+```
34+
35+Contohnya, bina fail baru bernama `mail.php` seperti berikut:-
36+
37+```php
38+<?php
39+require 'vendor/autoload.php';
40+
41+$transport = Swift_SmtpTransport::newInstance('127.0.0.1', 25);
42+$mailer = Swift_Mailer::newInstance($transport);
43+
44+$message = Swift_Message::newInstance('Wonderful Subject')
45+ ->setFrom(array('john@doe.com' => 'John Doe'))
46+ ->setTo(array('kamal-test@mailinator.com'))
47+ ->setBody('Here is the message itself')
48+ ;
49+
50+$result = $mailer->send($message);
51+```
52+
53+Dan anda boleh jalankannya melalui `php mail.php` dan email akan dihantar.

Built with git-ssb-web