-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreadme.txt
72 lines (58 loc) · 4.08 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Cloud-Rules-for-PHP_CodeSniffer
===============================
The cloud rules for PHP_CodeSniffer assist the PHP developer in developing new application
designed to scale when hosted in the cloud. It can also be used for analyzing existing on
premises code that needs to be refactored for scalability.
A cloud platform supporting PaaS is able to scale a PHP application designed to be scalable
based on its traffic needs and makes the overall administration easier by shielding the
developer from hardware failures and infrastructure management. These applications should
not maintain their state themselves between requests. All the PHP functions that work with
local file system, session memory and DB should use instead the storage capabilities offered
by the cloud platform to ensure that applications are stateless and therefore scalable.
In the same way a scalable Windows Azure application should not create an affinity with a
particular role instance as there is no guarantee that multiple requests from the same user
will be sent to the same instance. Instead, any client-specific state should be written
to Windows Azure storage, stored in SQL Azure Database, or maintained externally in some other way.
This package contains:
- A set of generic Platform as a Service rules for PHP_CodeSniffer located in the CloudPaaS folder.
- A set of Windows Azure rules for PHP_CodeSniffer that takes into consideration the custom storage
offered by Windows Azure and located in the WindowsAzure folder.
- A PHP sample application that uses local file system and the correspondent redesigned for scalability
version located in the Samples\DemoGallery folder.
- A PHP sample application that is stateless Samples\DemoWindowsAzureGallery folder.
The advantage of the static analysis is that developer gets feedback the earliest coding phase
without having to deploy the code in the cloud. On the other side static analysis is not
identifying the whole code stack and the rules may generate false positives or may as well
miss issues due to usage of reflection or usage of file paths as URIs in stream functions or
usage of other PECL extensions. To control the false positives the sniffs provide different error
messages, severity or warning/error level depending on the PHP community needs or the targeted
Cloud Provider.
We are hoping that the Cloud PHP_CodeSniffer rules will be extended with new custom rules from other
cloud providers.
How to run the PHP_CodeSniffer rules
====================================
Installation
------------
Please refer to the readme.txt files for installing CloudPaaS or WindowsAzure sniffs and additional examples.
Run the sniffs against generic Cloud Provider rules:
----------------------------------------------------
phpcs --standard=CloudPaaS <your PHP application root >
Download demoGallery https://github.com/downloads/Interop-Bridges/Cloud-Rules-for-PHP_CodeSniffer/DemoGallery.zip and
extract into <Your Project folder >
phpcs --standard=CloudPaaS demoGallery
Scoping the analysis to selected sniffs:
phpcs --standard=CloudPaaS --sniffs=CloudPaaS.Functions.Session demoGallery
phpcs --standard=CloudPaaS --sniffs=CloudPaaS.Functions.LocalFileSystem,CloudPaaS.Functions.Session demoGallery
Run the sniffs against Windows Azure rules:
-------------------------------------------
phpcs --standard=CloudPaaS <your PHP application root >
Download demoGallery https://github.com/downloads/Interop-Bridges/Cloud-Rules-for-PHP_CodeSniffer/DemoGallery.zip and
extract into <Your Project folder >
phpcs --standard=WindowsAzure demoGallery
Both CloudPaaS and WindowsAzure sniff sets cover the PHP functions that work with local file
system and DB and store session information into memory. The only difference between the
two sets is the error message and the severity of the errors as well as what is
considered error versus what is considered warning.
The PHP developer targeting a cloud platform with support for certain databases could exclude
those databases from the analysis either by updating the ruleset.xml file either by filtering
the sniffs from command line.