1 PHP na Windows Artur Żarski [email protected] Developer Evangelist3/28/2017 4:53 AM PHP na Windows Artur Żarski Developer Evangelist Microsoft Corporation © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
2 Plan spotkania IIS7 jako platforma PHP na WindowsSQL Server Driver for PHP Expression Web 2 Inne możliwości współdziałania
3 Microsoft i OpenSource?3/28/2017 4:53 AM Microsoft i OpenSource? © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
4 3/28/2017 4:53 AM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
5 Przykłady projektów PHPAzure API for PHP Phalanger PHP4VS WindowsLive for PHP PHPOpenXML API PHPRPC for .NET Excel document creation via OpenXML for PHP PHP Linq
6 3/28/2017 4:53 AM IIS7 - platforma © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
7 Zalety IIS 7.0 Modularna architektura aby zredukować możliwość atakuKonfiguracja systemu oparta na XML Możliwość zdalnego zarządzania Zaawansowana diagnostyka Integracja z WMS oraz Media Pack Możliwość rozszerzenia IIS7 przy użyciu kodu zarządzanego
8 Dlaczego warto przejść na IIS7? (1/2)Konfiguracja w pliku tekstowym Apache: httpd.conf ale wymaga restartu przez admina IIS7: bez restartu + command line Rozproszona konfiguracja Apache: .htaccess Asp.net: web.config
9 Dlaczego warto przejść na IIS7? (2/2)Zaawansowana diagnostyka oraz rozwiązywanie problemów 'failed request tracing‘ request monitoring and runtime data Administracja i API AppCmd.exe WMI provider Microsoft.Web.Administration Inne: Application Request Routing Web Deployment Tool Bitrate Throttling / Smooth Streaming …
10 IIS7 .NET Extensibility – Moduł vs. HandlerModuły dostarczają usługi dla wszystkich żądań moduł Basic Authentication moduł Compression Handlery dostarczają usługi dla specyficznych rozszerzeń ISAPI handler (.dll) Static handler (.htm, .jpg, .gif, etc) IIS 7 pozwala na zarządzanie natywnymi i „zarządzanymi” modułami oraz handlerami. public class BasicAuthenticationModule : System.Web.IHttpModule { void Init(HttpApplication context) { } void Dispose() { } } Describe the difference between a handler and module. When would you use one vs. the other? Show the sections in Applicationhost.config where handler and module are defined. Note the “precondition” setting for managed code handlers indicates the module is only used if the Application Pool is in Integrated mode.
11 Skrypty: nowy WMI ProviderSet oService = GetObject("winmgmts:root\WebAdministration") ' Tworzymy binding dla witryny Set oBinding = oService.Get("BindingElement").SpawnInstance_ oBinding.BindingInformation = "*:80:www.site.com" oBinding.Protocol = "http" ‘ Tworzymy witrynę oService.Get("Site").Create _ "NewSite", array(oBinding), "C:\inetpub\wwwroot" ' Tworzymy aplikację oService.Get("Application").Create _ "/foo", "NewSite", "C:\inetpub\wwwroot\foo"
12 Appcmd – listowanie i filtrowaniePotężne narzędzie do zarządzania IIS 7 z linii komend C:\> appcmd list sites SITE "Default Web Site" (id:1,bindings:HTTP/*:80:,state:Started) SITE "Site1" (id:2,bindings:http/*:81:,state:Started) SITE "Site2" (id:3,bindings:http/*:82:,state:Stopped) C:\> appcmd list requests REQUEST "fb e" (url:GET /wait.aspx?time=10000,time:4276 msec,client:localhost) C:\> appcmd list requests /apppool.name:DefaultAppPool C:\> appcmd list requests /wp.name:3567 C:\> appcmd list requests /site.id:1
13 Programowanie: Microsoft.Web.AdministrationNowe APIs pozwala programistom na pisanie własnych narzędzi do wdrażania, zarządzania ASP.NET oraz IIS ServerManager iisManager = new ServerManager(); foreach(WorkerProcess w3wp in iisManager.WorkerProcesses) { Console.WriteLine("W3WP ({0})", w3wp.ProcessId); foreach (Request request in w3wp.GetRequests(0)) { Console.WriteLine("{0} - {1},{2},{3}", request.Url, request.ClientIPAddr, request.TimeElapsed, request.TimeInState); } }
14 Demo IIS7
15 PHP na Windows
16 Najważniejsze elementy3/28/2017 4:53 AM ADOdb Pierwszy projekt Open Source, w którym MS brał udział SQL Server PHP Driver SQL Server Driver for PHP został stworzony aby umożliwić współpracę PHP z SQL Server IIS7+ FastCGI Podstawa PHP na Windows A few examples: Microsoft / Zend Technologies collaboration PHP optimized for Windows IIS FastCGI: solid platform for PHP on IIS 6/7 Tested/insured compatibility with many popular PHP applications Ongoing focus on making Windows/IIS an excellent platform for PHP applications Microsoft has provided a patch that provides ADOdb database abstraction layer support for the PHP SQL driver. What may be more significant to open-source advocates is that Microsoft is licensing the patch under the Free Software Foundation's lesser GPL (LGPL) licensing terms. SQL SERVER DRIVER The SQL Server Driver for PHP is designed to enable reliable, scalable integration with SQL Server for PHP applications deployed on the Windows platform. The Driver for PHP is a PHP 5 extension that allows the reading and writing of SQL Server data from within PHP scripts. It provides a procedural interface for accessing data in all Editions of SQL Server 2005 and SQL Server 2008 (including Express Editions), and makes use of PHP features, including PHP streams to read and write large objects. The release of SQL Server Driver for PHP v1.0 marks another step in Microsoft’s continued commitment to interoperability. Earlier this year, the release of IIS 7.0 and its FastCGI support was the major step towards making Windows the platform of choice for both developing and deploying PHP applications. To show our level of commitment to the PHP community, we've also posted the source code for our driver to Microsoft's CodePlex site. This release of the SQL Server PHP driver makes it easier for the PHP development community to use SQL Server as their database of choice for PHP applications. We encourage you to download our driver and explore the sample application described in the .chm file. If you'd prefer to access our documentation on-line, it's available on the MSDN site. To keep up with our announcements and customer feedback, please check out our team blog or the MSDN forum site for the driver. IIS7 IIS 7.0 offers new capabilities that dramatically improve the way Web solutions are developed, deployed, and managed. Modular architecture in IIS 7 provides additional functionality to PHP applications. IIS had always supported PHP, but in a way that precluded many real-life PHP applications from being hosted in production environments. This was due to limitations in the two ways IIS offered for running PHP applications: using the Common Gateway Interface (CGI) protocol or using the PHP ISAPI extension. Because CGI requires a separate process for each request, apps hosted using CGI would perform poorly on Windows. Conversely, PHP apps using the IIS high-performance multithreaded ISAPI interface would often suffer from instability due to the lack of thread safety in some popular PHP extensions. In an attempt to solve these problems, the IIS team developed the FastCGI component. The open FastCGI protocol allows PHP and many other application frameworks that require a single-threaded environment (including Ruby on Rails, Perl, and Python) to run more reliably on IIS. Unlike the standard CGI implementation, FastCGI enables process reuse by maintaining a pool of worker processes, each processing no more than one request at a time, thus resulting in much-improved performance. FastCGI also benefitted from a community-centric development and testing model. Expression WEB 2.0 About Expression Microsoft Expression Studio takes your creative possibilities to a new level. The professional design tools and innovative technologies in Expression Studio give you the flexibility and freedom to bring your vision to reality—whether you are designing standards-based Web sites, rich user experiences for the desktop and Silverlight, or managing digital assets and content. Edit PHP pages Broaden your scope by now editing PHP sites with Expression Web 2. Apply the full set of standards based design tools to a wider range of sites. Expression Web 2.0 Wsparcie narzędzi MS do pracy z PHP © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
17 IIS FastCGI Solidna platforma dla aplikacji PHP vs. ISAPI: vs. CGI:Otwarty standard Wspierane przez środowisko PHP oraz wiele innych frameworków open source (RoR, Perl, Python, …) Ulepszenie CGI Web server tworzy proces FastCGI dla pierwszego żądania Web server wykorzystuje istniejące procesy FastCGI dla następnych żądań Konfigurowalne zasoby vs. ISAPI: Dostarcza wymaganą stabilność dla aplikacji PHP typu non-thread-safe vs. CGI: Drastyczny wzrost wydajności
18 IIS FastCGI – Zasada działaniaFastCGI process pool for PHP5 IIS Worker Process FastCGI handler ASP.NET Static FastCGI over named pipes lub TCP Read Configuration Authenticate Authorize Map Request Handle Request Send Response Log Request php-cgi.exe FastCGI process pool for PHP4 Request queue php.exe
19 Uruchomienie aplikacji PHP na IIS 7.0Łatwy setup: Instalacja PHP z FastCGI Wdrożenie aplikacji Kompatybilność: Top 10 aplikacji PHP testowane i udokumentowane na Łatwa migracja ze wsparciem Url Rewrite
20 Demo PHP
21 SQL Server PHP Driver Zalety:Pozwala na pewną i skalowaną integrację z SQL Server Tworzenie aplikacji na silnym i bezpiecznym silniku BD BI oraz SQL Reporting Services Konfiguracja: Php.ini -> extension=php_sqlsrv.dll Połączenie: $serverName = "(local)"; $connectionOptions = array("Database"=>"AdventureWorks");
22 Demo SQL driver for PHP
23 Microsoft® Expression® Web 2PHP 5.2.5, Fast CGI Intellisense, code-coloring oraz snippety Podgląd „PHP include” w trybie projektowanie Podgląd stron PHP na różnych zainstalowanych przeglądarkach przy pomocy wbudowanego Webservera
24 Demo Expression Web 2
25 PHP na Windows – dalsze możliwości
26 PHP i Silverlight Działa na IIS i ApacheWymaga dodania dwóch MIME types dla Silverlight .xaml – application/xaml+xml .xab – application/x-silverlight-app Brak ustawień = błąd 404.3
27 PHP i ASP.NET Membership + AJAXKompletne zarządzane API PHP on Windows Microsoft SQL Server Driver for PHP Web Services .NET / COM PHP On Linux FreeTDS Sockets
28 PHP i obiekty COM Czym jest COM (Component Object Model) ?PHP tak naprawdę nie używa COM. COM jest dowolnym językiem Windows VB C++ Delphi Python Perl Cobol Fortran COM - standard definiowania i tworzenia interfejsów programistycznych na poziomie binarnym dla komponentów software wprowadzony przez firmę Microsoft wraz z bibliotekami zapewniającymi podstawowe ramy i usługi dla współdziałania komponentów COM i aplikacji.
29 Tworzenie obiektów COMsomeMethod(“Some Argument”); ?>
30 Inne możliwości Microsoft Office Web Services Microsoft .NETNuSOAP PHP 5 – Native SOAP Extension ezSOAP PEAR::SOAP Microsoft .NET Microsoft Services (np. Live, Azure) Phalanger
31 PHP – „Wish List” Natywne API dla Active Directory AzMan API dla PHPPHP Bridge dla ADAM ASP.NET 2.0 Authentication Provider dla PHP A CDO / Exchange Bridge dla PHP PHP-Nuke, Mambo, etc. etc. Na MS SQL Server Opcjonalnie dla Phalanger Opcjonalnie dla AD
32 Common Language RuntimeVS.NET System.Web (ASP.NET) System.WinForms SessionState UI C# Caching HtmlControls Design ComponentModel JScript Security WebControls Configuration System.Drawing VB Simple Web Services Drawing2D Printing VC/MC++ Protocols Discovery Description Imaging Text Debugger Designers System.Data (ADO.NET) System.Xml ADO SQL XPath XSLT Serialization SDK Tools Design Adapters CorDBG System ILAsm Collections IO Security Runtime ILDbDump Configuration Net ServiceProcess InteropServices Diagnostics Reflection Text Remoting SN Globalization Resources Threading Serialization ILDAsm Common Language Runtime MetaInfo GC App Domain Loader JIT PEVerify MSIL Common Type System Class Loader Platform Abstraction Threads Boot Loader Sync Timers Networking Filesystem
33 Podsumowanie
34 3/28/2017 4:53 AM © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.