{"action":"created","issue":{"url":"https://api.github.com/repos/xp-framework/rfc/issues/119","labels_url":"https://api.github.com/repos/xp-framework/rfc/issues/119/labels{/name}","comments_url":"https://api.github.com/repos/xp-framework/rfc/issues/119/comments","events_url":"https://api.github.com/repos/xp-framework/rfc/issues/119/events","html_url":"https://github.com/xp-framework/rfc/issues/119","id":1930213,"number":119,"title":"Support self-running XARs","user":{"login":"kiesel","id":127769,"avatar_url":"https://avatars.githubusercontent.com/u/127769?v=3","gravatar_id":"","url":"https://api.github.com/users/kiesel","html_url":"https://github.com/kiesel","followers_url":"https://api.github.com/users/kiesel/followers","following_url":"https://api.github.com/users/kiesel/following{/other_user}","gists_url":"https://api.github.com/users/kiesel/gists{/gist_id}","starred_url":"https://api.github.com/users/kiesel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiesel/subscriptions","organizations_url":"https://api.github.com/users/kiesel/orgs","repos_url":"https://api.github.com/users/kiesel/repos","events_url":"https://api.github.com/users/kiesel/events{/privacy}","received_events_url":"https://api.github.com/users/kiesel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/xp-framework/rfc/labels/framework","name":"framework","color":"118f5b"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2011-10-17T15:56:15Z","updated_at":"2016-01-24T22:13:56Z","closed_at":"2016-01-24T22:13:56Z","body":"Scope of Change\n====\nThe framework's core will support running programs straight out \nof XAR files with no further infrastructure required (except a \nworking PHP binary).\n\nRationale\n====\nThis will faciliate providing single file applications, such as\ndesktop (GTK) applications and eg. installers.\nFurther, it'd become possible to ship console programs and even\nwhole web applications that can be installed by copying over a \nsingle file into the document root.\n\nFunctionality\n====\nSelf-running xars are a PHP file with the framework's bootstrap file\nlang.base.php's contents at the top and a complete XAR file after the\n__halt_compiler(); marker. Additionally the XAR file optionally contains\na special file named META-INF/manifest.ini in it: This file contains\nmeta-information about the archive and the name of the default\nclass to run open invocation.\n\nSelf-running xars need to be prepared in a special way:\n. create xar containing all files:\n  + \"core\" class files\n  + application specific files\n  + meta information for the runner\n. prepend contents of lang.base.php\n\nThe final file can be run by just invoking php on it:\n\n\n```\n$ php runner.xar\n\n```\n\nBecause the xar is prepended with lang.base.php's contents, it will\nbe run and detect that it's not running in standard mode, but in\nself-running mode.\nUnlike in standard mode, lang.base.php will load the class \nlang.archive.ArchiveRunner and pass control this class' run method, in\nwhich the program execution is triggered.\n\nOnce the program flow returns to lang.base.php, it'll immediately\nstop execution with the exit() command.\n\nThe lang.archive.ArchiveRunner is responsible for\n. determining the sapi\n. loading META-INF/manifest.ini, if needed\n. depending on the sapi, find the class to run\n\nDetermining the class to run is dependent to the sapi due to different\nways how the environment signals users choices which class to run:\n+ for a console application, command line arguments may be used\n  to select the class to run\n+ for web applications GET or POST parameters or cookies may have\n  influence on the decision.\n\nThe META-INF/manifest.ini can contain the following information:\n\n\n```\n  [sapi::cli]\n  main-class=\"fully.qualified.ClassName\"\n  \n  [sapi::web]\n  main-class=\"fully.qualified.ClassName\"\n\n```\n\nSecurity considerations\n====\nn/a\n\nSpeed impact\n====\nIt is a requirement that this change does not impact speed of\nthe framework.\n\nDependencies\n====\n\nRelated documents\n====\n- http://experiments.xp-framework.net/?people,kiesel,php,selfrunning\n  Prove of concept experiment\n\n- http://xp-framework.net/rfc/0108.rfc.html\n  xp-framework/rfc #108: Make XAR files runnable by XPCLI\n\n"},"comment":{"url":"https://api.github.com/repos/xp-framework/rfc/issues/comments/174346411","html_url":"https://github.com/xp-framework/rfc/issues/119#issuecomment-174346411","issue_url":"https://api.github.com/repos/xp-framework/rfc/issues/119","id":174346411,"user":{"login":"thekid","id":696742,"avatar_url":"https://avatars.githubusercontent.com/u/696742?v=3","gravatar_id":"","url":"https://api.github.com/users/thekid","html_url":"https://github.com/thekid","followers_url":"https://api.github.com/users/thekid/followers","following_url":"https://api.github.com/users/thekid/following{/other_user}","gists_url":"https://api.github.com/users/thekid/gists{/gist_id}","starred_url":"https://api.github.com/users/thekid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thekid/subscriptions","organizations_url":"https://api.github.com/users/thekid/orgs","repos_url":"https://api.github.com/users/thekid/repos","events_url":"https://api.github.com/users/thekid/events{/privacy}","received_events_url":"https://api.github.com/users/thekid/received_events","type":"User","site_admin":false},"created_at":"2016-01-24T22:13:56Z","updated_at":"2016-01-24T22:13:56Z","body":"Hasn't been important for 8 years. Closing."}}