forked from rosswintle/can-i-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
293 lines (270 loc) · 9.94 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="canonical" href="https://caniphp.com/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="og:title"
content="Can I PHP? - caniuse.com but for PHP features"
/>
<meta name="og:description" content="caniuse.com but for PHP features" />
<meta
name="og:image"
content="https://can-i-use.com/images/can-i-php-screen.png"
/>
<title>Can I PHP? - caniuse.com but for PHP features</title>
<meta
name="description"
content="A list of PHP features and the versions of PHP that they are present in. Like caniuse.com but for PHP!"
/>
<link href="/dist/style.css" rel="stylesheet" />
</head>
<body>
<div
id="app"
x-data="features"
class="text-center pt-6 pb-24 px-6 md:w-2/3 max-w-4xl mx-auto"
>
<header class="mb-12">
<div class="mb-14 text-sm">
<a
class="underline hover:no-underline"
href="https://github.com/rosswintle/can-i-php/blob/main/README.md"
>README.md</a
>
—
<a
class="underline hover:no-underline"
href="https://github.com/rosswintle/can-i-php"
>GitHub</a
>
— By
<a
class="underline hover:no-underline"
href="https://twitter.com/magicroundabout"
>@magicroundabout</a
>
—
<a
class="underline hover:no-underline"
href="https://ko-fi.com/magicroundabout"
>Buy me coffee</a
>
OR
<a class="underline hover:no-underline" href="https://turbo-admin.com"
>Check out my WordPress Browser Extension</a
>
</div>
<div class="mb-4 text-2xl">
<strong>Unofficial</strong> and <em>incomplete</em>
</div>
<h1 class="text-6xl tracking-wider font-bold mb-3">Can I PHP?</h1>
<p class="text-center mx-auto lg:w-2/3">
PHP feature support by version - like caniuse.com but for PHP.<br />
This is a list of language features and functions added or removed in
recent PHP versions. It is not an exhaustive reference.
</p>
</header>
<main>
<form action="" @submit.prevent="">
<input
x-model="searchString"
type="search"
name="s"
placeholder="Search for a PHP feature"
class="w-full md:w-2/3 mb-6 md:mb-16 text-xl md:text-3xl py-4 px-6 border-2 rounded-md"
/>
</form>
<div
class="text-left prose lg:prose-xl"
x-show="filteredFeatures().length === 0"
>
<h3>Nothing matches!</h3>
<p>It could be that:</p>
<ul>
<li>
We know about the thing, but your search didn't find it - try
again! If you think search didn't work for a given feature, please
raise an issue or PR on
<a href="https://github.com/rosswintle/can-i-php">
the GitHub repo</a
>
to improve the keywords.
</li>
<li>
The feature was not added in, deprecated from or removed from a
recent PHP version. caniphp.com is not a list of ALL PHP functions
and features, just those added or removed in recent versions.
</li>
<li>
We don't know about the thing yet. The information here is being
manually curated, and is not yet complete. So please bear with us
as we add more data, or contribute what you were looking for on
<a href="https://github.com/rosswintle/can-i-php">GitHub.</a>
</li>
</ul>
<p>
If you think something is missing then feel free to open a pull
request on
<a href="https://github.com/rosswintle/can-i-php"
>the GitHub repo</a
>
to add it.
</p>
</div>
<div class="text-left">
<template x-for="feature in filteredFeatures()">
<!-- Feature panel -->
<article class="w-full mb-6">
<!-- Feature info -->
<div class="w-full border border-b-none py-2 px-4">
<h2 x-text="feature.name" class="text-lg mb-4 font-bold"></h2>
<div class="flex">
<!-- Feature top panel, left column -->
<div class="w-3/4 pr-4">
<p
x-html="formatAsHtml(feature.description)"
class="mb-6"
></p>
<h3 class="font-bold text-l mb-2">Resources</h3>
<ul
x-show="feature?.resources?.length > 0"
class="list-disc list-inside text-sm mb-4"
>
<template x-for="resource in feature.resources">
<li>
<a
x-text="resource.name"
class="underline hover:no-underline"
:href="resource.url"
></a>
</li>
</template>
</ul>
</div>
<div class="w-1/4 pl-4">
<p x-show="feature.added && feature.added !== '0.0'">
Added: PHP v<span x-text="feature.added"></span>
</p>
<p x-show="feature.deprecated">
Deprecated: PHP v<span x-text="feature.deprecated"></span>
</p>
<p x-show="feature.removed">
Removed: PHP v<span x-text="feature.removed"></span>
</p>
</div>
</div>
</div>
<!-- Feature versions - colored boxes -->
<div class="flex w-full overflow-auto">
<template x-for="version in versions">
<div
class="flex-1 px-3 py-2 text-center"
:class="featureSupportedIn(feature, version.version) ? 'bg-green-300 font-bold' : 'bg-red-300'"
>
<span x-text="version.version"></span>
</div>
</template>
</div>
</article>
</template>
</div>
</main>
</div>
<!-- Fathom - beautiful, simple website analytics -->
<script
src="https://polished-thirtyfive.caniphp.com/script.js"
data-site="IULNCQBS"
defer
></script>
<!-- / Fathom -->
<script src="versions.js"></script>
<script src="features.js"></script>
<script src="//unpkg.com/alpinejs" defer></script>
<script>
document.addEventListener("alpine:init", () => {
document.querySelector("input[name=s]").focus();
const url = new URL(window.location.href);
const searchParam = url.searchParams.get("s");
Alpine.data("features", () => {
return {
// searchString: window.location.pathname.slice(1) ?? '',
searchString: searchParam ?? "",
versions: versions,
init() {
this.$watch("searchString", (value) => {
const url = new URL(window.location.href);
url.searchParams.set("s", value);
history.replaceState(null, "", url);
});
},
versionCompare(v1, v2) {
if (v1 === v2) {
return 0;
}
const v1parts = v1.split(".");
const v2parts = v2.split(".");
if (v1parts[0] > v2parts[0]) {
return 1;
}
if (v1parts[0] < v2parts[0]) {
return -1;
}
return v1parts[1] > v2parts[1] ? 1 : -1;
},
featureSupportedIn(feature, version) {
// Can't tell if feature is added
if (feature.added === null) {
return false;
}
// Feature is not yet added in this version
if (this.versionCompare(feature.added, version) === 1) {
return false;
}
// Feature is added, removal is not specified
if (feature.removed === null) {
return true;
}
// Feature is removed
if (this.versionCompare(feature.removed, version) <= 0) {
return false;
}
// Feature is added and not removed
return true;
},
filteredFeatures() {
return this.featuresHaving(this.searchString);
},
featureMatches(feature, keyword) {
keyword = keyword.toLowerCase();
return (
feature.name.toLowerCase().includes(keyword) ||
feature.description.toLowerCase().includes(keyword) ||
feature.keywords.some((featureKeyword) =>
featureKeyword.toLowerCase().includes(keyword)
)
);
},
featuresHaving(featureKeyword) {
const versions = features.filter((feature) =>
this.featureMatches(feature, featureKeyword)
);
return versions;
},
/*
* This does some basic formatting.
*
* - backticks are converted to <code></code>
*/
formatAsHtml(rawString) {
htmlString = rawString.replace(/`(.*?)`/g, "<code>$1</code>");
return htmlString;
},
};
});
});
</script>
</body>
</html>