netico-Bones-Configuration.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Documentation</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <base href="../">
  8. <link rel="icon" href="images/favicon.ico"/>
  9. <link rel="stylesheet" href="css/normalize.css">
  10. <link rel="stylesheet" href="css/base.css">
  11. <link rel="preconnect" href="https://fonts.gstatic.com">
  12. <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap" rel="stylesheet">
  13. <link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
  14. <link rel="stylesheet" href="css/template.css">
  15. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
  16. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
  17. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
  18. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
  19. <script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
  20. <script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
  21. <script src="js/search.js"></script>
  22. <script defer src="js/searchIndex.js"></script>
  23. </head>
  24. <body id="top">
  25. <header class="phpdocumentor-header phpdocumentor-section">
  26. <h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">Documentation</a></h1>
  27. <input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
  28. <label class="phpdocumentor-header__menu-icon" for="menu-button">
  29. <i class="fas fa-bars"></i>
  30. </label>
  31. <section data-search-form class="phpdocumentor-search">
  32. <label>
  33. <span class="visually-hidden">Search for</span>
  34. <svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
  35. <circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
  36. <line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
  37. </svg>
  38. <input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
  39. </label>
  40. </section>
  41. <nav class="phpdocumentor-topnav">
  42. <ul class="phpdocumentor-topnav__menu">
  43. </ul>
  44. </nav>
  45. </header>
  46. <main class="phpdocumentor">
  47. <div class="phpdocumentor-section">
  48. <input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
  49. <label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
  50. Menu
  51. </label>
  52. <aside class="phpdocumentor-column -four phpdocumentor-sidebar">
  53. <section class="phpdocumentor-sidebar__category">
  54. <h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
  55. <h4 class="phpdocumentor-sidebar__root-namespace">
  56. <a href="namespaces/netico.html" class="">netico</a>
  57. </h4>
  58. <ul class="phpdocumentor-list">
  59. <li>
  60. <a href="namespaces/netico-bones.html" class="">Bones</a>
  61. </li>
  62. </ul>
  63. </section>
  64. <section class="phpdocumentor-sidebar__category">
  65. <h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
  66. <h4 class="phpdocumentor-sidebar__root-namespace">
  67. <a href="packages/bones.html" class="">bones</a>
  68. </h4>
  69. </section>
  70. <section class="phpdocumentor-sidebar__category">
  71. <h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
  72. <h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
  73. <h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
  74. <h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
  75. </section>
  76. <section class="phpdocumentor-sidebar__category">
  77. <h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
  78. <h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
  79. </section>
  80. </aside>
  81. <div class="phpdocumentor-column -eight phpdocumentor-content">
  82. <ul class="phpdocumentor-breadcrumbs">
  83. <li class="phpdocumentor-breadcrumb"><a href="namespaces/netico.html">netico</a></li>
  84. <li class="phpdocumentor-breadcrumb"><a href="namespaces/netico-bones.html">Bones</a></li>
  85. </ul>
  86. <article class="phpdocumentor-element -class">
  87. <h2 class="phpdocumentor-content__title">
  88. Configuration
  89. <div class="phpdocumentor-element__package">
  90. in package
  91. <ul class="phpdocumentor-breadcrumbs">
  92. <li class="phpdocumentor-breadcrumb"><a href="packages/bones.html">bones</a></li>
  93. </ul>
  94. </div>
  95. </h2>
  96. <aside class="phpdocumentor-element-found-in">
  97. <abbr class="phpdocumentor-element-found-in__file" title="src/Classes/Configuration.php"><a href="files/src-classes-configuration.html"><abbr title="src/Classes/Configuration.php">Configuration.php</abbr></a></abbr>
  98. :
  99. <span class="phpdocumentor-element-found-in__line">38</span>
  100. </aside>
  101. <p class="phpdocumentor-summary">The Configuration class retrieves configuration variables from an .ini file.</p>
  102. <section class="phpdocumentor-description"><p>It requires the path to the configuration file.
  103. As for security, keeping the configuration file out of the web root is the first step.
  104. Making it read-only and restricting access may make it more secure.
  105. The .ini files have a trivial syntax so they are easy to edit and understand.
  106. Also it is the syntax of PHP configuration files.</p>
  107. <pre class="prettyprint"><code class="prettyprint"> [application]
  108. name=foo
  109. [template]
  110. name=bar
  111. [sqlite]
  112. database=/path/to/file.sqlite
  113. </code></pre>
  114. <p>And then:</p>
  115. <pre class="prettyprint"><code class="prettyprint"> $c = new \netico\Bones\Configuration();
  116. $name = $c-&gt;getValue('application', 'name');
  117. print $name;
  118. </code></pre>
  119. </section>
  120. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  121. Tags
  122. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  123. </h5>
  124. <dl class="phpdocumentor-tag-list">
  125. <dt class="phpdocumentor-tag-list__entry">
  126. <span class="phpdocumentor-tag__name">link</span>
  127. </dt>
  128. <dd class="phpdocumentor-tag-list__definition">
  129. <a class="phpdocumentor-tag-link" href="https://git.lattuga.net/netico/code-library/src/master/Framework"> https://git.lattuga.net/netico/code-library/src/master/Framework </a>
  130. </dd>
  131. <dt class="phpdocumentor-tag-list__entry">
  132. <span class="phpdocumentor-tag__name">copyright</span>
  133. </dt>
  134. <dd class="phpdocumentor-tag-list__definition">
  135. <section class="phpdocumentor-description"><p>Copyright (c) 2016, 2022 netico <a href="mailto:netico@riseup.net">netico@riseup.net</a></p>
  136. </section>
  137. </dd>
  138. <dt class="phpdocumentor-tag-list__entry">
  139. <span class="phpdocumentor-tag__name">license</span>
  140. </dt>
  141. <dd class="phpdocumentor-tag-list__definition">
  142. <section class="phpdocumentor-description"><p>https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License</p>
  143. </section>
  144. </dd>
  145. <dt class="phpdocumentor-tag-list__entry">
  146. <span class="phpdocumentor-tag__name">author</span>
  147. </dt>
  148. <dd class="phpdocumentor-tag-list__definition">
  149. <section class="phpdocumentor-description"><p>netico <a href="mailto:netico@riseup.net">netico@riseup.net</a></p>
  150. </section>
  151. </dd>
  152. </dl>
  153. <h3 id="toc">
  154. Table of Contents
  155. <a href="#toc" class="headerlink"><i class="fas fa-link"></i></a>
  156. </h3>
  157. <dl class="phpdocumentor-table-of-contents">
  158. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  159. <a href="classes/netico-Bones-Configuration.html#method___construct">__construct()</a>
  160. <span>
  161. &nbsp;: void </span>
  162. </dt>
  163. <dd>This code works if you set the CONFIG constant.</dd>
  164. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  165. <a href="classes/netico-Bones-Configuration.html#method_getValue">getValue()</a>
  166. <span>
  167. &nbsp;: string </span>
  168. </dt>
  169. <dd>This method gets a configuration option.</dd>
  170. </dl>
  171. <section class="phpdocumentor-methods">
  172. <h3 class="phpdocumentor-elements__header" id="methods">
  173. Methods
  174. <a href="classes/netico-Bones-Configuration.html#methods" class="headerlink"><i class="fas fa-link"></i></a>
  175. </h3>
  176. <article
  177. class="phpdocumentor-element
  178. -method
  179. -public
  180. "
  181. >
  182. <h4 class="phpdocumentor-element__name" id="method___construct">
  183. __construct()
  184. <a href="classes/netico-Bones-Configuration.html#method___construct" class="headerlink"><i class="fas fa-link"></i></a>
  185. </h4>
  186. <aside class="phpdocumentor-element-found-in">
  187. <abbr class="phpdocumentor-element-found-in__file" title="src/Classes/Configuration.php"><a href="files/src-classes-configuration.html"><abbr title="src/Classes/Configuration.php">Configuration.php</abbr></a></abbr>
  188. :
  189. <span class="phpdocumentor-element-found-in__line">49</span>
  190. </aside>
  191. <p class="phpdocumentor-summary">This code works if you set the CONFIG constant.</p>
  192. <code class="phpdocumentor-code phpdocumentor-signature ">
  193. <span class="phpdocumentor-signature__visibility">public</span>
  194. <span class="phpdocumentor-signature__name">__construct</span><span>(</span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">void</span></code>
  195. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  196. <span class="phpdocumentor-signature__response_type">void</span>
  197. &mdash;
  198. </article>
  199. <article
  200. class="phpdocumentor-element
  201. -method
  202. -public
  203. "
  204. >
  205. <h4 class="phpdocumentor-element__name" id="method_getValue">
  206. getValue()
  207. <a href="classes/netico-Bones-Configuration.html#method_getValue" class="headerlink"><i class="fas fa-link"></i></a>
  208. </h4>
  209. <aside class="phpdocumentor-element-found-in">
  210. <abbr class="phpdocumentor-element-found-in__file" title="src/Classes/Configuration.php"><a href="files/src-classes-configuration.html"><abbr title="src/Classes/Configuration.php">Configuration.php</abbr></a></abbr>
  211. :
  212. <span class="phpdocumentor-element-found-in__line">96</span>
  213. </aside>
  214. <p class="phpdocumentor-summary">This method gets a configuration option.</p>
  215. <code class="phpdocumentor-code phpdocumentor-signature ">
  216. <span class="phpdocumentor-signature__visibility">public</span>
  217. <span class="phpdocumentor-signature__name">getValue</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$section</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$name</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">string</span></code>
  218. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  219. <dl class="phpdocumentor-argument-list">
  220. <dt class="phpdocumentor-argument-list__entry">
  221. <span class="phpdocumentor-signature__argument__name">$section</span>
  222. : <span class="phpdocumentor-signature__argument__return-type">string</span>
  223. </dt>
  224. <dd class="phpdocumentor-argument-list__definition">
  225. <section class="phpdocumentor-description"><p>Section in INI file (for example: '[section]').</p>
  226. </section>
  227. </dd>
  228. <dt class="phpdocumentor-argument-list__entry">
  229. <span class="phpdocumentor-signature__argument__name">$name</span>
  230. : <span class="phpdocumentor-signature__argument__return-type">string</span>
  231. </dt>
  232. <dd class="phpdocumentor-argument-list__definition">
  233. <section class="phpdocumentor-description"><p>Key in file INI (for example: 'key=').</p>
  234. </section>
  235. </dd>
  236. </dl>
  237. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  238. <span class="phpdocumentor-signature__response_type">string</span>
  239. &mdash;
  240. <section class="phpdocumentor-description"><p>Value (for example: '=value').</p>
  241. </section>
  242. </article>
  243. </section>
  244. <script type="text/javascript">
  245. function loadExternalCodeSnippets(line) {
  246. Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach((pre) => {
  247. var src = pre.getAttribute('data-src').replace( /\\/g, '/');
  248. var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
  249. var language = 'php';
  250. var code = document.createElement('code');
  251. code.className = 'language-' + language;
  252. pre.textContent = '';
  253. pre.setAttribute('data-line', line)
  254. code.textContent = 'Loading…';
  255. pre.appendChild(code);
  256. var xhr = new XMLHttpRequest();
  257. xhr.open('GET', src, true);
  258. xhr.onreadystatechange = function () {
  259. if (xhr.readyState == 4) {
  260. if (xhr.status < 400 && xhr.responseText) {
  261. code.textContent = xhr.responseText;
  262. Prism.highlightElement(code);
  263. }
  264. else if (xhr.status >= 400) {
  265. code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
  266. }
  267. else {
  268. code.textContent = '✖ Error: File does not exist, is empty or trying to view from localhost';
  269. }
  270. }
  271. };
  272. xhr.send(null);
  273. });
  274. }
  275. var modals = document.querySelectorAll("[data-modal]");
  276. modals.forEach(function (trigger) {
  277. trigger.addEventListener("click", function (event) {
  278. //event.preventDefault();
  279. const modal = document.getElementById(trigger.dataset.modal);
  280. modal.classList.add("phpdocumentor-modal__open");
  281. loadExternalCodeSnippets(trigger.dataset.line)
  282. const exits = modal.querySelectorAll("[data-exit-button]");
  283. exits.forEach(function (exit) {
  284. exit.addEventListener("click", function (event) {
  285. event.preventDefault();
  286. modal.classList.remove("phpdocumentor-modal__open");
  287. });
  288. });
  289. });
  290. });
  291. </script>
  292. </article>
  293. <section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
  294. <section class="phpdocumentor-search-results__dialog">
  295. <header class="phpdocumentor-search-results__header">
  296. <h2 class="phpdocumentor-search-results__title">Search results</h2>
  297. <button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
  298. </header>
  299. <section class="phpdocumentor-search-results__body">
  300. <ul class="phpdocumentor-search-results__entries"></ul>
  301. </section>
  302. </section>
  303. </section>
  304. </div>
  305. </div>
  306. <a href="classes/netico-Bones-Configuration.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
  307. </main>
  308. <script>
  309. cssVars({});
  310. </script>
  311. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
  312. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
  313. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
  314. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
  315. </body>
  316. </html>