Skip to content

Commit 955e080

Browse files
committed
Add cpu info and fix links
1 parent 72074e3 commit 955e080

8 files changed

Lines changed: 213 additions & 21 deletions

File tree

Writerside/boson.tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</toc-element>
5353
<toc-element topic="components.md">
5454
<toc-element topic="os-info.md" />
55+
<toc-element topic="cpu-info.md" />
5556
</toc-element>
5657
<toc-element toc-title="Integrations">
5758
<toc-element topic="static-files.md" />

Writerside/cfg/buildprofiles.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
<noindex-content>false</noindex-content>
1414
<offline-docs>false</offline-docs>
1515

16-
<feedback-url>https://github.com/BosonPHP/Docs/issues</feedback-url>
16+
<feedback-url>https://github.com/boson-php/docs/issues</feedback-url>
1717
<web-root>/</web-root>
1818
<og-image>splash.png</og-image>
1919
<generate-canonicals>true</generate-canonicals>
2020

2121
<download-title>GitHub</download-title>
22-
<download-page>https://github.com/BosonPHP</download-page>
22+
<download-page>https://github.com/boson-php</download-page>
2323
<showDownloadButton>true</showDownloadButton>
2424

2525
<enable-contribution>true</enable-contribution>
26-
<contribute-url>https://github.com/BosonPHP/Docs/blob/master/Writerside/</contribute-url>
26+
<contribute-url>https://github.com/boson-php/docs/blob/master/Writerside/</contribute-url>
2727
<custom-css>custom.css</custom-css>
2828

2929
<algolia-id>VQXMLE2UOI</algolia-id>
@@ -37,11 +37,11 @@
3737
</icons>
3838

3939
<footer>
40-
<social type="github" href="https://github.com/BosonPHP">GitHub</social>
40+
<social type="github" href="https://github.com/boson-php">GitHub</social>
4141
<social type="telegram" href="https://t.me/boson_php">Telegram</social>
4242
<link href="https://packagist.org/packages/boson-php">Packagist</link>
43-
<link href="https://github.com/BosonPHP/Runtime/issues">Issue tracker</link>
44-
<link href="https://github.com/BosonPHP/Runtime/pulls">Submit request</link>
43+
<link href="https://github.com/boson-php/runtime/issues">Issue tracker</link>
44+
<link href="https://github.com/boson-php/runtime/pulls">Submit request</link>
4545
<copyright>Boson</copyright>
4646
</footer>
4747
</buildprofiles>

Writerside/topics/application/application-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ tools</a> (if they are not set explicitly).
114114
<secondary-label ref="config-only"/>
115115

116116
Specifies the path to a custom
117-
[frontend library](https://github.com/BosonPHP/Frontend/releases) that should
117+
[frontend library](https://github.com/boson-php/frontend-src/releases) that should
118118
be loaded with the application.
119119

120120
```php
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Central Processor Info
2+
3+
<show-structure for="chapter" depth="2"/>
4+
5+
The CPU info component provides information about the underlying CPU,
6+
including architecture, number of cores, and other information.
7+
8+
## Installation
9+
10+
<tldr>
11+
<p>
12+
Via <a href="https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies">Composer</a>:
13+
</p>
14+
<p>
15+
<code lang="bash">composer require boson-php/cpu-info</code>
16+
</p>
17+
</tldr>
18+
19+
**Requirements:**
20+
21+
* `PHP ^8.4`
22+
* `ext-ffi` (optional, provides more detailed and accurate information about the CPU)
23+
* `ext-com_dotnet` (optional, provides more detailed and accurate information about the CPU)
24+
25+
## Usage
26+
27+
### Basic Information
28+
29+
<secondary-label ref="macos-limitations"/>
30+
31+
```php
32+
use Boson\Component\CpuInfo\CentralProcessor;
33+
34+
// Get current CPU information
35+
$cpu = CentralProcessor::createFromGlobals();
36+
37+
// Access basic information
38+
echo 'Architecture: ' . $cpu->arch . "\n";
39+
echo 'Name: ' . $cpu->name . "\n";
40+
echo 'Vendor: ' . ($cpu->vendor ?? '~') . "\n";
41+
echo 'Physical Cores: ' . $cpu->physicalCores . "\n";
42+
echo 'Logical Cores: ' . $cpu->logicalCores . "\n";
43+
echo 'Instruction Sets: ' . implode(', ', $cpu->instructionSets);
44+
```
45+
46+
This code will output something like the following information:
47+
48+
<tabs>
49+
<tab title="Windows / x86_64">
50+
<code-block>
51+
Architecture: amd64
52+
Name: Intel(R) Core(TM) i7-10700KF CPU @ 3.80GHz
53+
Vendor: GenuineIntel
54+
Physical Cores: 8
55+
Logical Cores: 16
56+
Instruction Sets: mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, fma3, avx, avx2
57+
</code-block>
58+
</tab>
59+
<tab title="Linux / x86_64">
60+
<code-block>
61+
Architecture: amd64
62+
Name: Intel(R) Core(TM) i7-10700KF CPU @ 3.80GHz
63+
Vendor: GenuineIntel
64+
Physical Cores: 2
65+
Logical Cores: 4
66+
Instruction Sets: mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2
67+
</code-block>
68+
<note>This is an example output from VirtualBox, so the number of cores is
69+
different. Also, VirtualBox does not support AVX instruction set, so
70+
these instructions are not in the list.</note>
71+
</tab>
72+
</tabs>
73+
74+
### CPU Architecture
75+
76+
You can get the CPU architecture information from the CPU information
77+
object (`$cpu->arch`). However, if you do not need all the CPU information,
78+
it is enough to get the architecture separately using the
79+
`Architecture::createFromGlobals()` method.
80+
81+
```php
82+
use Boson\Component\CpuInfo\Architecture;
83+
84+
// Get current CPU architecture
85+
$arch = Architecture::createFromGlobals();
86+
87+
// Check for specific architecture
88+
if ($arch === Architecture::Amd64) {
89+
// Only amd64 (x86_64) specific code
90+
}
91+
92+
// Check for сompatible architectures
93+
if ($arch->is(Architecture::x86)) {
94+
// x86 and x86-like, for example:
95+
// - x86
96+
// - amd64 (x86_64)
97+
}
98+
```
99+
100+
The component supports the following architectures:
101+
- `Architecture::x86`
102+
- `Architecture::Amd64`
103+
- `Architecture::Arm`
104+
- `Architecture::Arm64`
105+
- `Architecture::Itanium`
106+
- `Architecture::RiscV32`
107+
- `Architecture::RiscV64`
108+
- `Architecture::Mips`
109+
- `Architecture::Mips64`
110+
- `Architecture::PowerPc`
111+
- `Architecture::PowerPc64`
112+
- `Architecture::Sparc`
113+
- `Architecture::Sparc64`
114+
115+
### Instruction Sets
116+
117+
<secondary-label ref="macos-limitations"/>
118+
119+
The component provides information about supported CPU instruction sets.
120+
You can check if a specific instruction set is supported:
121+
122+
```php
123+
use Boson\Component\CpuInfo\CentralProcessor;
124+
use Boson\Component\CpuInfo\InstructionSet;
125+
126+
$cpu = CentralProcessor::createFromGlobals();
127+
128+
// Check if specific instruction set is supported
129+
if ($cpu->isSupports(InstructionSet::AVX2)) {
130+
// AVX2 specific code
131+
}
132+
```
133+
134+
<tabs>
135+
<tab title="x86 / amd64 (x86_64)">
136+
<list>
137+
<li><code>InstructionSet::MMX</code> - MultiMedia eXtensions</li>
138+
<li><code>InstructionSet::SSE</code> - Streaming SIMD Extensions</li>
139+
<li><code>InstructionSet::SSE2</code> - Streaming SIMD Extensions 2</li>
140+
<li><code>InstructionSet::SSE3</code> - Streaming SIMD Extensions 3</li>
141+
<li><code>InstructionSet::SSSE3</code> - Supplemental Streaming SIMD Extensions 3</li>
142+
<li><code>InstructionSet::SSE4_1</code> - Streaming SIMD Extensions 4.1</li>
143+
<li><code>InstructionSet::SSE4_2</code> - Streaming SIMD Extensions 4.2</li>
144+
<li><code>InstructionSet::FMA3</code> - Fused Multiply-Add 3</li>
145+
<li><code>InstructionSet::AVX</code> - Advanced Vector Extensions</li>
146+
<li><code>InstructionSet::AVX2</code> - Advanced Vector Extensions 2</li>
147+
<li><code>InstructionSet::AVX512</code> - Advanced Vector Extensions 512</li>
148+
</list>
149+
</tab>
150+
<tab title="arm / arm64 (aarch64)">
151+
There is currently no support for checking instructions for this platform
152+
</tab>
153+
</tabs>
154+
155+
<tabs>
156+
<tab title="MacOS">
157+
<warning>
158+
Please note that the instruction set information in macOS may not be
159+
accurate due to virtualization and testing issues.
160+
161+
Full implementation of macOS support is possible in the future.
162+
</warning>
163+
</tab>
164+
</tabs>

Writerside/topics/components/os-info.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ supported standards.
2828

2929
### Basic Detection
3030

31+
<secondary-label ref="macos-limitations"/>
32+
3133
```php
3234
use Boson\Component\OsInfo\OperatingSystem;
3335

@@ -66,6 +68,21 @@ This code will output something like the following information
6668
Standards: POSIX
6769
</code-block>
6870
</tab>
71+
<tab title="macOS">
72+
<code-block>
73+
Family: Darwin
74+
Name: Darwin
75+
Version: 24.4.0
76+
Codename: ~
77+
Edition: ~
78+
Standards: POSIX
79+
</code-block>
80+
<warning>
81+
Please note that the information in macOS may not be accurate due
82+
to virtualization and testing issues.
83+
Full implementation of macOS support is possible in the future.
84+
</warning>
85+
</tab>
6986
</tabs>
7087

7188
### OS Families
@@ -81,9 +98,18 @@ use Boson\Component\OsInfo\Family;
8198
// Get current OS family
8299
$family = Family::createFromGlobals();
83100

84-
// Check for specific family
85-
if ($family->is(Family::Windows)) {
86-
// Windows-specific (or windows-like) code
101+
// Strict compliance
102+
if ($family === Family::BSD) {
103+
// Only BSD OS
104+
}
105+
106+
// Compatibility check
107+
if ($family->is(Family::BSD)) {
108+
// BSD and BSD-like, for example:
109+
// - BSD
110+
// - Solaris
111+
// - Darwin (macOS)
112+
// - etc
87113
}
88114
```
89115

Writerside/topics/contribution.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ the <a href="contribution.md#security-issues">special procedure instead</a>.
3939
</warning>
4040

4141
You may submit a bug report using GitHub Issues.
42-
- [Documentation](https://github.com/BosonPHP/Docs/issues)
43-
- [Boson Runtime Component (boson-php/runtime)](https://github.com/BosonPHP/Runtime/issues)
44-
- [Frontend Binaries](https://github.com/BosonPHP/Frontend/issues)
42+
- [Documentation](https://github.com/boson-php/docs/issues)
43+
- [Boson Kernel (monorepo)](https://github.com/boson-php/boson/issues)
4544

4645
Please follow some basic rules:
4746

@@ -107,7 +106,7 @@ provide a bug fix or to propose enhancements to Boson Components.
107106
Add the upstream repository as a remote:
108107
<code-block lang="Bash">
109108
cd COMPONENT_NAME
110-
git remote add upstream https://github.com/BosonPHP/COMPONENT_NAME.git
109+
git remote add upstream https://github.com/boson-php/COMPONENT_NAME.git
111110
</code-block>
112111
</step>
113112
</procedure>

Writerside/topics/getting-started/introduction.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ what you can expect on each one:
6363

6464
Are you getting stuck anywhere? Here are a few links to places to look:
6565

66-
If you need help with developing your app, our community [Telegram](https://t.me/boson_php) is a great place to get advice from
67-
other Boson app developers.
68-
69-
If you suspect you're running into a bug with the package, please check the [GitHub](https://github.com/BosonPHP/Runtime)
70-
issue tracker to see if any existing issues match your problem. If not, feel free
71-
to fill out our bug report template and submit a new issue.
66+
If you need help with developing your app, our community
67+
[Telegram](https://t.me/boson_php) is a great place to get advice from other
68+
Boson app developers.
69+
70+
If you suspect you're running into a bug with the package, please check the
71+
[GitHub](https://github.com/boson-php/runtime) issue tracker to see if any
72+
existing issues match your problem. If not, feel free to fill out our bug
73+
report template and submit a new issue.

Writerside/topics/overview.topic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
summary="Check out all the possibilities of building lightweight and powerful client solutions on PHP">
1818
Documentation
1919
</a>
20-
<a href="https://github.com/BosonPHP/Runtime" type="mixed"
20+
<a href="https://github.com/boson-php/runtime" type="mixed"
2121
summary="Boson is a completely open source solution">
2222
Source Code
2323
</a>

0 commit comments

Comments
 (0)