Presentation given by Manuel Lemos in Microsoft Web Development Summit 2008 about suggestions of things that Microsoft could do or help doing to make PHP run better on Windows
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
What Could Microsoft Do To Make PHP Run Better On Windows
1. What could Microsoft do to make PHP
run better on Windows
Manuel Lemos
mlemos@prophp.com.br
www.prophp.com.br
www.php.org.br
Microsoft Web Dev Summit 2008
Redmond, November 18, 2008
2. The problems
● PHP Windows developers face challenges that they
would not face when using PHP on other platforms
● Some PHP features do not work well on Windows
● Some Windows specific features are not supported
directly by PHP extensions
● PHP core lacks of Windows developers
● “PHP Windows developers are second-class citizens”
– Rasmus Lerdord – PHP creator
● Microsoft may help
4. Finding and sharing PHP components
for Windows
● Some problems can be solved with pure PHP code
● PHPClasses.org site distributes contributed solutions
in the form of classes of objects
● Anybody can contribute with their own PHP classes
● There is a category for Windows specific components:
www.phpclasses.org/browse/class/69.html
5. Accessing Windows shares that
require authentication
● PHP cannot access files on Windows remote shares
that require authentication
● Victor Varela from Spain solved the problem with the
stream wrapper class SMB4PHP:
www.phpclasses.org/smb4php
● It uses smbclient program to access files with names
with the format:
smb://user:password@host/path/to/share
6. Sending email via SMTP server that
requires authentication
● PHP sends email via SMTP on Windows
● The mail() function does not support SMTP
authentication
● The MIME message class can solve that problem:
www.phpclasses.org/mimemessage
● It supports LOGIN, PLAIN, MD5, NTLM authentication
methods via SASL library:
www.phpclasses.org/sasl
● Comes with easy replacement function smtp_mail()
7. Sending e-mail via Microsoft
Exchange mail pickup folder
● PHP can queue email much faster when Microsoft
Exchange queue pickup folder is available
● Just create email files and drop in the pickup folder
● The MIME message class comes with a sub-class
specialized in queuing messages that way:
www.phpclasses.org/mimemessage
9. Windows implementation of
GetMXRR function
● The DNS MX records point to the SMTP server that
receives messages for a given domain
● Emulating a delivery to the SMTP server in the MX
records can be used to verify if a e-mail is valid
● GetMXRR() function returns the MX records but it is
not implemented in PHP under Windows
● A patch to PHP could enable the GetMXRR() function
under Windows, so very popular e-mail validation
components could also be used in PHP on Windows:
www.phpclasses.org/emailvalidation
10. HTTP NTLM authentication built-in
PHP
● NTLM protocol is used to authenticate users during
Windows logon
● Web servers that require this authentication on the
same Windows domain can reuse credentials to
avoid asking passwords again to the users
● PHP has built-in HTTP basic authentication support
but not NTLM. It depends on Web server extensions
and additional configuration not integrated with PHP
● Built-in NTLM authentication support independent of
the Web server would be better
11. Better file locking support on
Windows
● File locking is used to prevent corruption of files
being changed by multiple users at the same time
● Examples: content caching and access counters
● PHP file locking function flock() do not work well
under Windows
12. Making PHP extensions run with
stability in multithreaded Web servers
● Multithreaded Web servers like IIS and Apache 2
(worker) take less memory to serve the same number
of simultaneous HTTP requests
● Less memory per request leads to less costs to scale
● PHP is mostly thread-safe but some extensions and
dependency libraries aren't
● Making C/C++ code thread-safe is not a trivial task
● Dr. Sagar Chaki <chaki+@cs.cmu.edu> developed a
tool named Beacon to verify code thread safety
● Beacon could be used to certify which extensions are
thread-safe and which need to be fixed
13. Questions?
Thank you!
Manuel Lemos
mlemos@prophp.com.br
www.prophp.com.br
www.php.org.br