Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Saturday, October 29, 2016

Getting Started with Eclipse PDT (PHP Development Tools)

So... First thing first...is downloading the eclipse PDT. We can download it from this site :
http://www.eclipse.org/pdt/#download
After downloading and unzipping the eclipse pdt.. just hit eclipse.exe...


Next... Let's create a new PHP project...





Next.. Create a new php file:




OKiee.... Let's a Hellow World like usual... :D

To run it, right click on the file, then choose, Run as PHP web application :



Yaaaps..... That's the end of this post... :D

Go to the next part...

Wednesday, October 26, 2016

Laravel Paths

For laravel 5.3 :


Sunday, October 23, 2016

Create Package in Laravel 5.3 - Part I

So I have fresh laravel installation here... Then I'm gonna create a package example for my own need...:D
First let's create a new folder in our root directory, the folder name is "package" as shown below :
Next, let's create another folder inside of package. This folder will gonna be our name or vendor name then our package name [vendor or creator]/ [package name]
Next... let's add another folder called "src" :
Next,, open command prompt in windows, then go to that src folder, then type "composer init". Just follow the instruction :



Here is the result :
{my mistake, this composer.json should be outside of src folder >,<... So just move it outside like this :}

In order to make our package visible to laravel, we need to add some new config in laravel composer.json like this :
Execute "composer dump-autoload" to clear composer cache
Next is creating service-provider for our package,
Then... Move this HyosokaServiceProvider to src folder of our package :
Next,,, let's add HyosokaServiceProvider to laravel config provider :

Go to part II

Saturday, October 22, 2016

Create Custom Exception in PHP

For creating a new custom exception, we just need to extend the Exception class, as shown below :
To hit this exception, we just need to throw a new exception like this :
Then... The last part :
Result :

Monday, October 3, 2016

Contoh Task Scheduling di Laravel 5.3

Di sini kita akan bermain dengan task scheduling di laravel 5.3. So pertama-tama silahkan buat fresh laravel project... Terus kita buat command baru, pake perintah ini :
"php artisan make:console hisokaLog --command=hisoka:log"
Kita bakalan dapat file baru kek gini :
Eeeh... yg variabel $description itu bisa kita ganti jadi kek gini :
Terrrusss... command yg barusan kita buat ini didaftarin di array command di console kernel seperti terlihat di bawah :

Naaah... klu kita execute perintah "php artisan", kita bisa liad command yg barusan dibikin...
Yaaaaps.... berarti udah okieee... :D

Teruuus.... balik ke hisokaLog... didalam command hisokaLog kita ada method handle, naah method ini lah yang jadi inti dari command ini, jadi method handle ini bakalan selalu dieksekusi ketika commandnya dipanggil. So didalam handle ini kita bisa naro macem2 kyk ngirim email, cek status, cek database, dsb... di postingan ini kita bikin yang sederhana ajjah dulu, yaitu ngebuat log file... :D
Simple kaaan.... :D... Silahkan tambahkan kode berikut didalam handle method hisokaLog :

Naaah... terus kita eksekusi commandnya "php artisan hisoka:log"
Dan hasilnya bisa kita lihat difile log laravel di "storage-logs-laravel.log" :
Kereun kaaaah... wkwkkw... :D *ngasal... :D

Okiee... berikutnya adalah ngedaftarin commandnya ke task-scheduling... Jadi task scheduling dilaravel itu kyk loop yang selalu dieksekusi setiap periode waktu tertentu sesuai yang kita tentukan. So kembali ke file kernel sebelumnya dimana kita daftarin hisoka:log-nya, terus dibagian scheduling kita tambain kode ini :

Selese daaaah... :D... btw diatas kita pake schedulingnya everyMinute(), jadi setiap menit hisoka:command itu akan dipanggil/diexecute. Cumaaaaaan... itu klu udah diserver jadi tar dipanggil tiap menit, tapi karena kita dilokal environment, jadi execute schedulernya pake perintah "php artisan schedule:run".
 Jadi setelah beberapa kali jalanin schedule:run, laravel.log-nya jadi seperti ini :
Teruuusss...Untuk list lengkap scheduling method yg lain bisa dilihat dari dokumentasi laravel resminya kyk gini :

Sip sip... seperti ini ajjah contoh sederhana make Task Scheduling di laravel.... :)
Semoga bermanfaat... :)