createphar.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. $file = __DIR__.'/ProjectWithXsdExtensionInPhar.phar';
  3. if (is_file($file)) {
  4. @unlink($file);
  5. }
  6. $phar = new Phar($file, 0, 'ProjectWithXsdExtensionInPhar.phar');
  7. $phar->addFromString('ProjectWithXsdExtensionInPhar.php', <<<'EOT'
  8. <?php
  9. class ProjectWithXsdExtensionInPhar extends ProjectExtension
  10. {
  11. public function getXsdValidationBasePath()
  12. {
  13. return __DIR__.'/schema';
  14. }
  15. public function getNamespace()
  16. {
  17. return 'http://www.example.com/schema/projectwithxsdinphar';
  18. }
  19. public function getAlias()
  20. {
  21. return 'projectwithxsdinphar';
  22. }
  23. }
  24. EOT
  25. );
  26. $phar->addFromString('schema/project-1.0.xsd', <<<'EOT'
  27. <?xml version="1.0" encoding="UTF-8" ?>
  28. <xsd:schema xmlns="http://www.example.com/schema/projectwithxsdinphar"
  29. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  30. targetNamespace="http://www.example.com/schema/projectwithxsdinphar"
  31. elementFormDefault="qualified">
  32. <xsd:element name="bar" type="bar" />
  33. <xsd:complexType name="bar">
  34. <xsd:attribute name="foo" type="xsd:string" />
  35. </xsd:complexType>
  36. </xsd:schema>
  37. EOT
  38. );
  39. $phar->setStub('<?php Phar::mapPhar("ProjectWithXsdExtensionInPhar.phar"); require_once "phar://ProjectWithXsdExtensionInPhar.phar/ProjectWithXsdExtensionInPhar.php"; __HALT_COMPILER(); ?>');