Dokumen tersebut membahas tentang PHP Standards Recommendation (PSR) yang dikembangkan oleh PHP Framework Interop Group (PHP-FIG). PSR merupakan standar koding untuk PHP yang bertujuan agar berbagai framework PHP dapat saling bekerja sama dengan lebih baik."
s React.js a library or a framework? In any case, it is a new way of working that represents a revolution in the way of building web projects. It has very particular characteristics that allow us, for instance, to render React code from the server side, or to include React components from Twig tags. During this talk we will present React.js, we will explore how to take advantage of it from PHP projects and we will give answers to practical problems such as universal (isomorphical) rendering and the generation of React.js forms from Symfony forms without duplication of efforts.
Materi tentang instalasi ojs. Materi terebut disampaikan dalam workshop "Membangun Jurnal Online" yang diselenggarakan di Hotel Loji Solo pada akhir November 2017
Yushak Soesilo
yushak@sttintheos.ac.id
Firewall merupakan sistem yang dirancang untuk mencegah akses tak diinginkan ke dan dari jaringan internet dengan mengontrol, memfilter, dan memutuskan lalu lintas data berdasarkan aturan. Ada beberapa metode dan teknik yang digunakan firewall seperti packet filtering, stateful inspection, kontrol pengguna, kontrol layanan, dan arah kontrol. Jenis-jenis firewall meliputi packet filtering, NAT, circuit level gateway, virtual, application level gateway, transparent, dan hybrid firewall.
s React.js a library or a framework? In any case, it is a new way of working that represents a revolution in the way of building web projects. It has very particular characteristics that allow us, for instance, to render React code from the server side, or to include React components from Twig tags. During this talk we will present React.js, we will explore how to take advantage of it from PHP projects and we will give answers to practical problems such as universal (isomorphical) rendering and the generation of React.js forms from Symfony forms without duplication of efforts.
Materi tentang instalasi ojs. Materi terebut disampaikan dalam workshop "Membangun Jurnal Online" yang diselenggarakan di Hotel Loji Solo pada akhir November 2017
Yushak Soesilo
yushak@sttintheos.ac.id
Firewall merupakan sistem yang dirancang untuk mencegah akses tak diinginkan ke dan dari jaringan internet dengan mengontrol, memfilter, dan memutuskan lalu lintas data berdasarkan aturan. Ada beberapa metode dan teknik yang digunakan firewall seperti packet filtering, stateful inspection, kontrol pengguna, kontrol layanan, dan arah kontrol. Jenis-jenis firewall meliputi packet filtering, NAT, circuit level gateway, virtual, application level gateway, transparent, dan hybrid firewall.
Using JSON Web Tokens for REST Authentication Mediacurrent
This session will provide an introduction to JSON Web Tokens (JWT) (https://jwt.io/introduction/), advantages over other authentication methods, and how to use it to authenticate requests to Drupal REST resources. After this session, attendees will have a better understanding of how JWTs work and will be able to set up and use JWT for authenticating REST requests in Drupal.
- NIST guidelines support limited use of biometrics for authentication and recommend it only be used as part of multi-factor authentication along with a physical authenticator. Biometrics have limitations including probabilistic matching and inability to easily revoke templates.
- When biometrics are used, NIST requires a false match rate of 1 in 1000 or better, implementation of liveness detection, and preference for local rather than central matching to mitigate attacks.
- For AAL2 authentication on mobile, NIST recommends using multi-factor cryptographic software authenticators activated by a second factor like biometrics. Examples include FIDO protocols and Android's CryptoObject for authenticating to remote servers.
- Behavioral biometrics analyzing user
This document discusses best practices for designing RESTful web APIs. It covers topics such as using HTTP verbs for actions, providing sensible resource names, using response codes to indicate status, offering both JSON and XML formats, creating fine-grained resources, considering connectivity between resources, handling errors properly, using versioning, supporting pagination and partial responses, including timestamps in requests and responses, and authenticating via methods such as OAuth2. The document provides examples from existing APIs at companies like Facebook, Twilio, and LinkedIn.
Spring Boot - Uma app do 0 a Web em 30 minutosphelypploch
O documento descreve Spring Boot, um framework Java que permite alta produtividade no desenvolvimento de aplicações. Spring Boot utiliza convenções para configuração automática e elimina a necessidade de XML, permitindo foco na lógica de negócio. O documento também explica como construir uma aplicação simples de lista de convidados usando Spring Boot e suas dependências.
O documento discute arrays em Java, incluindo como criá-los, acessar elementos, percorrê-los e ordená-los. É explicado que arrays são objetos que armazenam múltiplas variáveis do mesmo tipo e que cada elemento tem um índice. Métodos como for, foreach, Arrays.sort(), Arrays.copyOf() e Arrays.fill() são apresentados para manipular arrays.
Modul Praktikum Pemrograman Berorientasi Objek (Chap.1-6)Debby Ummul
Modul ini membahas tentang pemrograman berorientasi objek dengan bahasa Java. Materi yang dibahas antara lain konsep dasar OOP, penggunaan array, konstruktor, exception handling, serta percabangan dan operator dalam Java."
Dokumen ini membahas tentang enkapsulasi dalam pemrograman berorientasi objek. Enkapsulasi berarti membungkus atau mempaketkan data dan metode di dalam kelas untuk melindungi data dan menyederhanakan penggunaan kelas. Enkapsulasi mendorong penggunaan abstraksi dan modularitas untuk membuat program lebih fleksibel dan mudah digunakan kembali.
Imagens, vamos falar sobre imagens! :D
Docker 17.06, dockerfile, build, multi-stage e muito mais!
Talk realizado durante o Meetup do Docker no Google-SP.
http://www.youtube.com/linuxtips
The document provides an overview of SObjectizer, an open source framework for building concurrent and event-driven applications in C++. It describes how SObjectizer was originally developed in the 1990s and has since evolved through several versions. The document then dives into key aspects of how SObjectizer works, including how an application is launched through an SObjectizer environment, how agents are defined and registered in cooperations, and how agents communicate asynchronously via messages. It provides an example of defining ping and pong messages and a simple ponger agent to demonstrate these concepts.
Este documento descreve listas duplamente encadeadas, incluindo sua estrutura de nós com ponteiros para frente e para trás, e como implementar operações como busca, inserção e remoção nestas listas.
Modul 2 teknik pemrograman mengenal bahasa c dan compilerBeny Abd
Mengenal bahasa C sebagai salah satu bahasa pemrograman. Mengidentifikasi struktur penulisan program bahasa C. Software yang digunakan sebagai compiler, cara instalasi dan penggunaan Compiler.
This document discusses object-oriented programming concepts like inheritance, polymorphism, overloading, and overriding. It provides examples of inheritance hierarchies for different types of birds. Inheritance allows subclasses to inherit attributes and methods from parent classes. Polymorphism means an object can have different implementations of the same method depending on its type. Overloading and overriding relate to creating multiple methods with the same name that differ in parameters or implementation.
This document provides an overview of object-oriented programming (OOP) concepts in PHP including classes, objects, encapsulation, polymorphism, inheritance, magic methods, interfaces, abstract classes, and type hinting. Key points covered include defining classes with properties and methods, instantiating objects from classes, visibility of properties and methods, extending and overriding parent classes, implementing interfaces, and using polymorphism through interfaces to allow different classes to be used interchangeably.
Using JSON Web Tokens for REST Authentication Mediacurrent
This session will provide an introduction to JSON Web Tokens (JWT) (https://jwt.io/introduction/), advantages over other authentication methods, and how to use it to authenticate requests to Drupal REST resources. After this session, attendees will have a better understanding of how JWTs work and will be able to set up and use JWT for authenticating REST requests in Drupal.
- NIST guidelines support limited use of biometrics for authentication and recommend it only be used as part of multi-factor authentication along with a physical authenticator. Biometrics have limitations including probabilistic matching and inability to easily revoke templates.
- When biometrics are used, NIST requires a false match rate of 1 in 1000 or better, implementation of liveness detection, and preference for local rather than central matching to mitigate attacks.
- For AAL2 authentication on mobile, NIST recommends using multi-factor cryptographic software authenticators activated by a second factor like biometrics. Examples include FIDO protocols and Android's CryptoObject for authenticating to remote servers.
- Behavioral biometrics analyzing user
This document discusses best practices for designing RESTful web APIs. It covers topics such as using HTTP verbs for actions, providing sensible resource names, using response codes to indicate status, offering both JSON and XML formats, creating fine-grained resources, considering connectivity between resources, handling errors properly, using versioning, supporting pagination and partial responses, including timestamps in requests and responses, and authenticating via methods such as OAuth2. The document provides examples from existing APIs at companies like Facebook, Twilio, and LinkedIn.
Spring Boot - Uma app do 0 a Web em 30 minutosphelypploch
O documento descreve Spring Boot, um framework Java que permite alta produtividade no desenvolvimento de aplicações. Spring Boot utiliza convenções para configuração automática e elimina a necessidade de XML, permitindo foco na lógica de negócio. O documento também explica como construir uma aplicação simples de lista de convidados usando Spring Boot e suas dependências.
O documento discute arrays em Java, incluindo como criá-los, acessar elementos, percorrê-los e ordená-los. É explicado que arrays são objetos que armazenam múltiplas variáveis do mesmo tipo e que cada elemento tem um índice. Métodos como for, foreach, Arrays.sort(), Arrays.copyOf() e Arrays.fill() são apresentados para manipular arrays.
Modul Praktikum Pemrograman Berorientasi Objek (Chap.1-6)Debby Ummul
Modul ini membahas tentang pemrograman berorientasi objek dengan bahasa Java. Materi yang dibahas antara lain konsep dasar OOP, penggunaan array, konstruktor, exception handling, serta percabangan dan operator dalam Java."
Dokumen ini membahas tentang enkapsulasi dalam pemrograman berorientasi objek. Enkapsulasi berarti membungkus atau mempaketkan data dan metode di dalam kelas untuk melindungi data dan menyederhanakan penggunaan kelas. Enkapsulasi mendorong penggunaan abstraksi dan modularitas untuk membuat program lebih fleksibel dan mudah digunakan kembali.
Imagens, vamos falar sobre imagens! :D
Docker 17.06, dockerfile, build, multi-stage e muito mais!
Talk realizado durante o Meetup do Docker no Google-SP.
http://www.youtube.com/linuxtips
The document provides an overview of SObjectizer, an open source framework for building concurrent and event-driven applications in C++. It describes how SObjectizer was originally developed in the 1990s and has since evolved through several versions. The document then dives into key aspects of how SObjectizer works, including how an application is launched through an SObjectizer environment, how agents are defined and registered in cooperations, and how agents communicate asynchronously via messages. It provides an example of defining ping and pong messages and a simple ponger agent to demonstrate these concepts.
Este documento descreve listas duplamente encadeadas, incluindo sua estrutura de nós com ponteiros para frente e para trás, e como implementar operações como busca, inserção e remoção nestas listas.
Modul 2 teknik pemrograman mengenal bahasa c dan compilerBeny Abd
Mengenal bahasa C sebagai salah satu bahasa pemrograman. Mengidentifikasi struktur penulisan program bahasa C. Software yang digunakan sebagai compiler, cara instalasi dan penggunaan Compiler.
This document discusses object-oriented programming concepts like inheritance, polymorphism, overloading, and overriding. It provides examples of inheritance hierarchies for different types of birds. Inheritance allows subclasses to inherit attributes and methods from parent classes. Polymorphism means an object can have different implementations of the same method depending on its type. Overloading and overriding relate to creating multiple methods with the same name that differ in parameters or implementation.
This document provides an overview of object-oriented programming (OOP) concepts in PHP including classes, objects, encapsulation, polymorphism, inheritance, magic methods, interfaces, abstract classes, and type hinting. Key points covered include defining classes with properties and methods, instantiating objects from classes, visibility of properties and methods, extending and overriding parent classes, implementing interfaces, and using polymorphism through interfaces to allow different classes to be used interchangeably.
Understanding REST-Based Services: Simple, Scalable, and Platform IndependentCharles Knight
The document discusses a debate between proponents of REST and SOAP web services. It notes that REST focuses on resources identified through URIs and standard HTTP methods, while SOAP is criticized as complex and brittle. Large companies are increasingly adopting REST due to its simplicity and ability to integrate with various technologies.
This document provides an introduction to Git and common Git workflows. It discusses what Git is, how it stores data as snapshots rather than file changes, and its advantages as a distributed version control system where the full code history is stored locally. It then demonstrates basic Git commands like init, add, commit, status, branch, merge, tag and working with remotes. Key points covered include initializing and cloning repositories, tracking changes, committing work, branching and merging, and sharing code via remote repositories.
The document discusses PHP coding standards and conventions. It introduces PSR (PHP Standards Recommendation), which includes standards for autoloading (PSR-0), basic coding (PSR-1), coding style (PSR-2), logging (PSR-3), and improved autoloading (PSR-4). It also discusses DocBlocks and PHP_CodeSniffer, which is a tool for checking code against coding standards.
This document summarizes key principles for building scalable, reliable and secure RESTful services using HTTP. It discusses how to ensure reliability through idempotent operations. It also covers techniques for scaling such as use of ETags, caching, content types and uniform resource locators (URLs). The document concludes with an overview of security considerations and tools that can be used including HTTP authentication, SSL and XML signature/encryption.
The document discusses PHP coding standards called PSRs (PHP Standards Recommendations), including PSR-0 for autoloading, PSR-1 for basic coding standards, PSR-2 for coding style, and PSR-3 for logging. It provides an overview of the key requirements of PSR-1 and PSR-2, such as use of namespaces, class and method naming conventions, indentation, line lengths, and brace and parenthesis placement. The goal of PSRs is to establish a common coding standard for PHP code.
SlideShare now has a player specifically designed for infographics. Upload your infographics now and see them take off! Need advice on creating infographics? This presentation includes tips for producing stand-out infographics. Read more about the new SlideShare infographics player here: http://wp.me/p24NNG-2ay
This infographic was designed by Column Five: http://columnfivemedia.com/
No need to wonder how the best on SlideShare do it. The Masters of SlideShare provides storytelling, design, customization and promotion tips from 13 experts of the form. Learn what it takes to master this type of content marketing yourself.
This document provides tips to avoid common mistakes in PowerPoint presentation design. It identifies the top 5 mistakes as including putting too much information on slides, not using enough visuals, using poor quality or unreadable visuals, having messy slides with poor spacing and alignment, and not properly preparing and practicing the presentation. The document encourages presenters to use fewer words per slide, high quality images and charts, consistent formatting, and to spend significant time crafting an engaging narrative and rehearsing their presentation. It emphasizes that an attractive design is not as important as being an effective storyteller.
10 Ways to Win at SlideShare SEO & Presentation OptimizationOneupweb
Thank you, SlideShare, for teaching us that PowerPoint presentations don't have to be a total bore. But in order to tap SlideShare's 60 million global users, you must optimize. Here are 10 quick tips to make your next presentation highly engaging, shareable and well worth the effort.
For more content marketing tips: http://www.oneupweb.com/blog/
This document provides tips for getting more engagement from content published on SlideShare. It recommends beginning with a clear content marketing strategy that identifies target audiences. Content should be optimized for SlideShare by using compelling visuals, headlines, and calls to action. Analytics and search engine optimization techniques can help increase views and shares. SlideShare features like lead generation and access settings help maximize results.
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...SlideShare
This document provides a summary of the analytics available through SlideShare for monitoring the performance of presentations. It outlines the key metrics that can be viewed such as total views, actions, and traffic sources over different time periods. The analytics help users identify topics and presentation styles that resonate best with audiences based on view and engagement numbers. They also allow users to calculate important metrics like view-to-contact conversion rates. Regular review of the analytics insights helps users improve future presentations and marketing strategies.
Each month, join us as we highlight and discuss hot topics ranging from the future of higher education to wearable technology, best productivity hacks and secrets to hiring top talent. Upload your SlideShares, and share your expertise with the world!
PHP Tips & Trik Lanjutan: Clean Code dan Coding StandarMedidu
Teks ini memberikan ringkasan tentang tips dan panduan praktis untuk mengerjakan proyek berbasis PHP dengan baik, meliputi topik seperti menerapkan clean code dan coding standard, meningkatkan keamanan PHP, memilih framework yang tepat, membuat dokumentasi, serta referensi PHP yang perlu diketahui.
PHP adalah bahasa skrip server-side yang digunakan untuk membangun situs web dinamis dan interaktif. Dokumen menjelaskan pengantar PHP, syntax dasar PHP, tipe data yang digunakan dalam PHP seperti string, integer, float, boolean, dan objek. Dokumen juga membahas variabel, konstanta, dan beberapa contoh kode PHP sederhana.
Modul ringkasan membahas pengenalan dasar PHP meliputi sejarah, pengertian, software pendukung, dan cara kerja PHP di server serta hukum penulisan sintaks PHP.
Bag 1. dasar PHP
Jika sistem Apache Web Server, PHP4, dan MySQL kita telah siap dan terkonfigurasi dengan benar, sekarang adalah
saatnya yang paling tepat untuk memulai perjalanan ini. Program "Hello World!" yang legendaris untuk memulai
belajar sebuah bahasa pemrograman, sengaja tidak dipakai karena kita tidak ingin meneruskan tradisi kuno ini. Ada
hal yang lebih berguna yang dapat kita pakai sebagai contoh. Anda bisa mulai memilih text editor favorit Anda (yang
jelas vi bukan sebuah program nyaman bagi pemula). Jika Anda bekerja di sistem operasi Windows, Anda bahkan
dapat memilih Lingkungan Pengembangan Terpadu/IDE (Integrated Development Environment) khusus untuk PHP
Silakan coba kode di bawah ini dan simpan sebagai file dengan ekstension .php, misalkan coba.php.
<?php
phpinfo();
?>
Untuk menjalankannya, kita bisa mulai membuka browser web kesukaan kita, kemudian arahkan alamat pada file
coba.php yang telah kita buat, misalkan alamatnya adalah http://localhost/coba.php, maka Anda akan mendapatkan
tampilan browser Anda berisikan parameter-parameter yang diset untuk PHP yang kita miliki. Anda dapat mengubah
parameter ini dengan memodifikasi file php.ini. Jika Anda memang benar-benar masih pemula, jangan kaget melihat
begitu banyaknya parameter yang harus diset untuk PHP Anda, karena akan saya beri tahu sebuah rahasia kecil
bahwa nilai parameter yang default sebenarnya sudah sangat lebih dari cukup untuk memulai belajar pemrograman
PHP 4.
Konsep pemrograman dengan PHP ini sedikit berbeda dengan pemrograman dengan menggunakan script CGI yang
memaksa kita untuk selalu menulis kode yang menghasilkan keluaran dalam format HTML. Pada PHP, kita diberikan
kebebasan untuk menyisipkan kode PHP di mana pun pada halaman HTML biasa dan menjalankan kode PHP tersebut
setiap ada permintaan terhadap halaman tersebut.
Berikut ini adalah cara menyisipkan kode PHP pada halaman HTML biasa.
Tutorial ini menjelaskan dasar-dasar kerangka kerja Laravel untuk pemula. Topik utama yang dibahas meliputi pengenalan Laravel, instalasi dan konfigurasi, routing dasar dan berparameter, serta pengenalan MVC dan templating Blade. Tulisan ini bertujuan membantu pembaca yang akan belajar Laravel dengan menjelaskan konsep-konsep dasar framework secara singkat dan mudah dipahami.
Tutorial ini membahas tentang dasar-dasar kerangka kerja Laravel untuk pembuatan aplikasi web PHP. Ia menjelaskan tentang pengenalan Laravel, proses instalasi, struktur proyek Laravel, dasar routing, MVC, template Blade, form dan migrasi database. Tulisan ini bertujuan membantu pemula mempelajari Laravel dengan cara yang mudah dipahami.
Teks tersebut membahas tentang pemrograman berorientasi fungsi dan beberapa konsep dasar dalam PHP seperti fungsi, tipe data, komentar, dan sintaks dasar PHP. Secara ringkas, teks tersebut menjelaskan bahwa PHP adalah bahasa pemrograman server-side yang berfokus pada penggunaan fungsi dan menyimpan kode PHP di antara tag khusus untuk dieksekusi di server.
Cara mudah mempelajari Laravel dengan teknik dasar pemrograman, sehingga memudahkan kepada para pemula untuk melatih menjadi seorang programmer. Dasar-dasar pemrograman untuk menjadi programmer yang handal. Mencakup instalasi laravel dan konfigurasi serta menggunakan fungsi-fungsi pada laravel.
Laravel adalah framework PHP populer untuk membangun aplikasi web dan API. Materi ini memperkenalkan konsep-konsep dasar Laravel seperti struktur proyek, penggunaan artisan, dependency injection, konfigurasi, dan testing.
[/ringkuman]
Dokumen tersebut membahas tentang algoritma pemrograman pada pertemuan ke-2. Terdiri dari beberapa bagian utama yaitu pendahuluan, judul algoritma, deklarasi, deskripsi, dan translasi teks algoritma ke bahasa pemrograman Pascal. Dokumen ini menjelaskan konsep-konsep dasar algoritma pemrograman seperti struktur, pengulangan, pemilihan, serta cara-cara menuliskan algoritma dan mengubahnya ke dalam bahasa pemro
Dokumen tersebut memberikan ringkasan tentang Laravel, sebuah framework PHP untuk membangun aplikasi berbasis web. Ia menjelaskan apa itu framework dan manfaatnya, serta langkah-langkah dasar untuk menginstal dan menggunakan Laravel seperti persiapan yang dibutuhkan, proses instalasi, dan konsep dasar MVC.
Optimize php application in high traffic environmentk4ndar
Dokumen tersebut memberikan rekomendasi untuk mengoptimalkan kinerja aplikasi PHP di lingkungan dengan lalu lintas tinggi, termasuk memperbarui PHP ke versi terbaru, melakukan profiling, mengurangi query ke database, menggunakan cache, dan mengkonfigurasi server secara tepat.
Similar to Mari Memahami PSR (PHP Standards Recommendation) (20)
11. PSR-0 Autoloading Standard
Bagaimana semua framework dapat bekerja sama?
● memiliki struktur direktori umum
● memilik standar autoloading umum.
JADI
Semua framework harus dibangun dengan menggunakan
konvensi autoloading yang sama.
12. PSR-0 Peraturan
1. Struktur Fully-qualified Namespace dan Class harus mengikuti struktur
<Vendor Name> (<Namespace>) * <Class Name>
2. Setiap Namespace harus memiliki top-level namespace (“Nama Vendor”).
3. Setiap Namespace dapat memiliki banyak sub-namespace sesuai
kebutuhan.
4. Setiap separator namespace diubah menjadi DIRECTORY_SEPARATOR
ketika loading dari sistem file.
5. Setiap karakter _ (Underscore) dalam CLASS NAME diubah menjadi
DIRECTORY_SEPARATOR. Karakter _ (Underscore) tidak memiliki arti
khusus dalam namespace.
6. Fully-qualified Namespace dan Class berakhiran .php ketika loading dari
sistem file.
7. Urutan abjad dalam penamaan vendor, namespace, dan class merupakan
kombinasi dari huruf kecil dan huruf besar.
16. PSR-1 Basic Coding Standard
Ini adalah tawaran PSR untuk standarisasi pengkodean
PHP, dan idenya adalah jika semua pengembang
menggunakan standar yang sama, maka akan mudah
untuk memindahkan modul tanpa masalah.
17. PSR-1 Peraturan
1. File HARUS menggunakan <?php dan <?= tags
2. File HARUS menggunakan UTF-8 tanpa BOM untuk PHP Code.
3. File SEBAIKNYA dapat mendeklarasikan simbol (classes, functions,
constants, dll) atau yang menyebabkan efek samping (generate output,
change .ini settings, dll) tapi HARUS TIDAK melakukan keduanya.
4. Namespace dan Class HARUS mengikuti PSR-0.
5. Nama Class HARUS dideklarasikan dalam StudlyCaps
6. Constant kelas HARUS dinyatakan dalam huruf besar semua dengan
pemisah underscore
7. Nama Method HARUS dinyatakan dalam CamelCase
18. PSR-1 Files
PHP Tags
PHP code HARUS menggunakan
<?php ?> atau short-echo <?= ?>
Tidak boleh menggunakan variasi lainnya.
Character Encoding
Kode PHP HARUS menggunakan UTF-8 tanpa BOM
19. PSR-1 Files
Side Effects
Contoh penggunaan deklarasi dan side effects bersamaan
yang harus dihindari
http://laravel.io/bin/YydOn
Contoh penggunaan deklarasi tanpa side effects
http://laravel.io/bin/mGMlj
20. PSR-1 Namespace & Class Name
● Namespace & Class Name HARUS mengikuti PSR-0
● Class Name HARUS StudlyCaps
Contoh Namespace dan Class Name
http://laravel.io/bin/bEBGX
21. PSR-1 Class Constant, Properties, Methods
Constant
Class Constant: upper case with underscore seperator
http://laravel.io/bin/Xy7Dj
Properties
Penamaan SEHARUSNYA konsisten sesuai scope. Contoh scope: vendor-level,
package-level, class-level, or method-level.
Methods
Method names HARUS camelCase()
23. PSR-2 Coding Style Guide
PSR ini penambahan dari PSR-1, dan
seperangkat aturan mengenai bagaimana
memformat kode PHP.
24. PSR-2 Peraturan
1. Kode HARUS berdasarkan PSR-1.
2. Kode harus menggunakan 4 spasi untuk indentasi, bukan tab.
3. TIDAK HARUS ada batas pada panjang baris; batas soft HARUS 120
karakter, setiap baris SEHARUSNYA 80 karakter atau kurang.
4. HARUS ada satu baris kosong setelah deklarasi namespace, dan HARUS
ada satu baris kosong setelah blok use deklarasi.
5. Pembuka Brace ( Kurung kurawal ) untuk Class HARUS pada baris
berikutnya, dan menutup Brace HARUS ada pada baris berikutnya setelah
body class.
6. Membuka Brace untuk method HARUS pada baris berikutnya, dan
menutup kawat gigi HARUS pada baris berikutnya setelah body method.
25. PSR-2 Peraturan (lanjutan)
7. Visibility HARUS dideklarasikan pada semua properti dan metode; abstract
dan final harus dideklarasikan sebelum Visibility, static HARUS
menyatakan setelah Visibility.
8. Control struktur keyword HARUS memiliki satu spasi setelahnya; namun
pada pemanggilan method dan function TIDAK HARUS.
9. Membuka Brace untuk struktur Control HARUS pada baris yang sama,
dan menutup kawat gigi HARUS pergi pada baris berikutnya setelah body
control.
10. Kurung buka untuk struktur kontrol TIDAK HARUS memiliki spasi setelah
mereka, dan menutup kurung untuk struktur kontrol TIDAK HARUS
memiliki spasi sebelumnya.
27. PSR-2 General
Basic Coding Standard
● Code HARUS mengikuti semua aturan PSR-1
Files
● Semua PHP files HARUS menggunakan Unix LF (linefeed) line ending
● Semua PHP files HARUS berakhir dengan single blank line
Lines
● HARUS TIDAK terlalu panjang barisnya.
● soft limit HARUS 120 karakter
● SEBAIKNYA 80 karakter
28. PSR-2 General
Indenting
● Code HARUS menggunakan 4 space untuk indenting
● Code HARUS TIDAK menggunaan tabs untuk indenting
N.b.: Using only spaces, and not mixing spaces with tabs, helps to avoid
problems with diffs, patches, history, and annotations. The use of spaces
also makes it easy to insert fine-grained sub-indentation for inter-line
alignment.
Keywords and True/False/Null
● PHP Keyword HARUS lower case
● PHP constants true, false, null HARUS lower case
29. PSR-2 Namespace & Declarations
● Setelah deklarasi namespace HARUS ada 1 baris kosong.
● Semua deklarasi use HARUS berada di bawah deklarasi namespace
● Deklarasi use HARUS untuk 1 keyword.
● Setelah deklarasi blok use HARUS ada 1 baris kosong.
Contoh
http://laravel.io/bin/1y4ne
30. PSR-2 Classes, Properties, Methods
Extends & Implements
● keyword extends dan implements HARUS
dideklarasikan dalam 1 baris
Contoh
http://laravel.io/bin/BLoka
● Beberapa implements BOLEH dipisah menjadi
beberapa baris, dimana setiap baris di-indent sekali.
Contoh
http://laravel.io/bin/2Wknr
31. PSR-2 Classes, Properties, Methods
Properties
● penglihatan/visibility HARUS dideklarasikan pada semua property
● keyword var, HARUS TIDAK digunakan untuk mendeklarasikan property
● HARUS TIDAK lebih dari 1 property per statement.
● SEBAIKNYA TIDAK diberi awalan single underscore ( _ ) untuk
mengindikasikan protected atau private visibility
Contoh
http://laravel.io/bin/VPzrn
32. PSR-2 Classes, Properties, Methods
Methods
● penglihatan/visibility HARUS dideklarasikan pada semua method
● Nama Method SEBAIKNYA TIDAK diberi awalan single underscore ( _ )
untuk mengindikasikan protected atau private visibility
● Nama Method HARUS TIDAK dideklarasikan dengan spasi setelah nama
method.
● Kurung buka dan kurung tutup HARUS berada dalam baris yang sama
dengan nama method.
● HARUS TIDAK boleh ada spasi setelah opening parenthesis dan sebelum
closing parenthesis.
● Contoh: http://laravel.io/bin/LkmGe
33. PSR-2 Classes, Properties, Methods
Method Arguments
● HARUS TIDAK ada space sebelum koma, dan HARUS ada space seteleh
setiap koma.
● Method arguments dengan nilai default HARUS berada dibelakang daftar
argumen.
Contoh: http://laravel.io/bin/wJnYx
● Daftar argumen BOLEH dipisah menjadi beberapa baris, dimana setiap
baris diberi 1 indent.
Contoh: http://laravel.io/bin/qQElo
34. PSR-2 Classes, Properties, Methods
abstract, final, and static
● Deklarasi abstract dan final HARUS berada sebelum deklarasi
visibility.
● Deklarasi static HARUS berada setelah deklarasi visibility.
● Contoh: http://laravel.io/bin/0e4yw
35. PSR-2 Classes, Properties, Methods
Method & Function
● HARUS TIDAK ada space antara nama method/function dengan kurung
buka dan HARUS TIDAK ada space setelah kurung buka
● HARUS TIDAK ada space sebelum kurung tutup dan HARUS TIDAK ada
space setelah kurung tutup.
Contoh: http://laravel.io/bin/7we1z
● Daftar argumen BOLEH dipotong menjadi beberapa baris, dimana setiap
baris diberi 1 indent.
Contoh: http://laravel.io/bin/jQyP7
36. PSR-2 Control Structures
● HARUS ada 1 spasi setelah control structures keyword
● HARUS TIDAK ada spasi setelah opening parenthesis
● HARUS TIDAK ada spasi sebelum closing parenthesis
● HARUS ada spasi antara closing parenthesis dengan
opening brace
● Structured body HARUS ada 1 indent
● Closing brace HARUS berada pada baris selanjutnya
setelah body.
37. PSR-2 Control Structures
● if, elseif, else
contoh: http://laravel.io/bin/8Kq37
● switch, case
contoh: http://laravel.io/bin/aNB5P
● while, do while
contoh: http://laravel.io/bin/okY2w
● for
contoh: http://laravel.io/bin/vB4mV
● foreach
contoh: http://laravel.io/bin/yGEYR
● try, catch
contoh: http://laravel.io/bin/52YWn
38. PSR-2 Closures
● Contoh deklarasi closure
http://laravel.io/bin/kWxk0
● Contoh deklarasi daftar argumen pada closure
http://laravel.io/bin/l5vxV
● Contoh deklarasi closure pada function or method call
http://laravel.io/bin/W4Q95
41. PSR-3 Logger Interface
Peraturan PSR-3 untuk logging, dan secara khusus
memaparkan sembilan metode untuk tata cara menulis log
pada library framework. Hal ini membuat pemangkasan
universal untuk semua kerangka, yang berarti akan
mempermudah ketika ingin menerapkan logging dalam
framework yang sebelumnya tidak mempunyai fungsi
tersebut.
42. PSR-3 Cara
1. LoggerInterface memperlihatkan delapan metode untuk menulis log ke
dalam RFC 5424 (debug, info, notice, warning, error, critical, alert,
emergency).
2. Metode kesembilan (log), menerima tingkat log sebagai argumen pertama.
Pemanggilan metode ini dengan salah satu dari tingkat konstanta log
HARUS memiliki hasil yang sama seperti pemanggilan metode tingkat-spesifik.
Pemanggilan metode ini dengan tidak disertai konstanta level oleh
HARUS mengeluarkan PsrLogInvalidArgumentException jika
pelaksanaannya tidak berhasil. Pengguna SEBAIKNYA TIDAK
menggunakan tingkat log kustom tanpa mengetahui pasti cara
pengimplementasiannya.
49. PSR-4 Improved Autoloading
Sebagai extention untuk PSR-0, PSR-4
menambahkan metode peningkatan
autoloading, dan juga menjelaskan persyaratan
path file dari autoloader interoperable.