@artilingo/artiframe-cli 1.4.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/core-stubs/bin/SystemMethod.php +600 -521
  2. package/core-stubs/bin/ViewMethod.php +591 -393
  3. package/core-stubs/docs/de.html +4347 -4390
  4. package/core-stubs/docs/en.html +4347 -4389
  5. package/core-stubs/docs/es.html +4347 -4390
  6. package/core-stubs/docs/fr.html +4347 -4389
  7. package/core-stubs/docs/tr.html +138 -109
  8. package/package.json +1 -1
  9. package/src/App.php +8 -0
  10. package/src/Commands/AddCommand.php +1 -1
  11. package/src/Commands/ListCommand.php +2 -1
  12. package/src/Commands/MakeApiCommand.php +1 -1
  13. package/src/Commands/MakeClassCommand.php +1 -1
  14. package/src/Commands/MakeViewCommand.php +1 -1
  15. package/src/Commands/NewProjectCommand.php +37 -25
  16. package/src/Commands/RemoveCommand.php +21 -10
  17. package/src/Commands/ServeCommand.php +29 -9
  18. package/src/Commands/TableCommand.php +2 -1
  19. package/src/Commands/UpgradeCommand.php +209 -0
  20. package/src/Commands/VersionCommand.php +2 -1
  21. package/src/Lang/de.php +7 -1
  22. package/src/Lang/en.php +6 -0
  23. package/src/Lang/es.php +7 -1
  24. package/src/Lang/fr.php +6 -0
  25. package/src/Lang/tr.php +7 -1
  26. package/src/Services/Safeguard.php +25 -0
  27. package/stubs/service/image.stub +334 -334
  28. package/stubs/service/iyzico.stub +637 -637
  29. package/stubs/service/jwt.stub +312 -312
  30. package/stubs/service/phpmailer.stub +143 -143
  31. package/stubs/service/pusher.stub +232 -232
  32. package/stubs/service/qrcode.stub +169 -169
  33. package/stubs/service/redis.stub +361 -361
  34. package/stubs/service/s3.stub +377 -377
  35. package/stubs/service/sentry.stub +76 -106
  36. package/stubs/service/stripe.stub +526 -526
  37. package/stubs/service/twilio.stub +361 -361
  38. package/core-stubs/app/R2Manager.php +0 -130
@@ -1,232 +1,232 @@
1
- <?php
2
-
3
- namespace Service;
4
-
5
- use Pusher\Pusher;
6
-
7
- /**
8
- * Pusher Realtime Service
9
- *
10
- * Provides a clean interface for Pusher Channels — broadcasting events,
11
- * authenticating private/presence channels, and querying channel state.
12
- * Uses the pusher/pusher-php-server SDK. All configuration from $_ENV.
13
- *
14
- * Required environment variables:
15
- * PUSHER_APP_ID — Your Pusher application ID
16
- * PUSHER_APP_KEY — Your Pusher application key
17
- * PUSHER_APP_SECRET — Your Pusher application secret
18
- * PUSHER_CLUSTER — Pusher cluster region (e.g., 'eu', 'us2', 'ap1')
19
- *
20
- * @package Service
21
- */
22
- class PusherService
23
- {
24
- /**
25
- * The Pusher SDK client instance.
26
- *
27
- * @var \Pusher\Pusher
28
- */
29
- private Pusher $pusher;
30
-
31
- /**
32
- * Create a new PusherService instance.
33
- *
34
- * Initializes the Pusher SDK client using credentials
35
- * and cluster configuration from environment variables.
36
- *
37
- * @throws \Pusher\PusherException If credentials are invalid or missing
38
- */
39
- public function __construct()
40
- {
41
- $this->pusher = new Pusher(
42
- $_ENV['PUSHER_APP_KEY'],
43
- $_ENV['PUSHER_APP_SECRET'],
44
- $_ENV['PUSHER_APP_ID'],
45
- [
46
- 'cluster' => $_ENV['PUSHER_CLUSTER'] ?? 'mt1',
47
- 'useTLS' => true,
48
- 'encrypted' => true,
49
- ]
50
- );
51
- }
52
-
53
- /**
54
- * Broadcast an event to a single channel.
55
- *
56
- * Triggers an event on the specified channel, delivering
57
- * the given data payload to all subscribers of that channel.
58
- *
59
- * Channel naming conventions:
60
- * - Public channels: 'my-channel'
61
- * - Private channels: 'private-my-channel'
62
- * - Presence channels: 'presence-my-channel'
63
- *
64
- * @param string $channel The channel name to broadcast on
65
- * @param string $event The event name to trigger
66
- * @param array $data The event payload data
67
- * @return bool True on success, false on failure
68
- */
69
- public function broadcast(string $channel, string $event, array $data): bool
70
- {
71
- try {
72
- $response = $this->pusher->trigger($channel, $event, $data);
73
-
74
- return (bool) $response;
75
- } catch (\Exception $e) {
76
- return false;
77
- }
78
- }
79
-
80
- /**
81
- * Broadcast an event to multiple channels simultaneously.
82
- *
83
- * Triggers the same event with the same payload across
84
- * multiple channels in a single API call. Pusher limits
85
- * this to a maximum of 100 channels per call.
86
- *
87
- * @param array $channels List of channel names (max 100)
88
- * @param string $event The event name to trigger
89
- * @param array $data The event payload data
90
- * @return bool True on success, false on failure
91
- */
92
- public function broadcastToMany(array $channels, string $event, array $data): bool
93
- {
94
- try {
95
- $response = $this->pusher->trigger($channels, $event, $data);
96
-
97
- return (bool) $response;
98
- } catch (\Exception $e) {
99
- return false;
100
- }
101
- }
102
-
103
- /**
104
- * Send an event to a specific user via their user channel.
105
- *
106
- * Uses Pusher's user event feature to deliver a message directly
107
- * to a single authenticated user, regardless of which channels
108
- * they are subscribed to. The user must have been authenticated
109
- * with a user ID on the client side.
110
- *
111
- * @param string $userId The target user's unique identifier
112
- * @param string $event The event name to trigger
113
- * @param array $data The event payload data
114
- * @return bool True on success, false on failure
115
- */
116
- public function toUser(string $userId, string $event, array $data): bool
117
- {
118
- try {
119
- $response = $this->pusher->sendToUser($userId, $event, $data);
120
-
121
- return (bool) $response;
122
- } catch (\Exception $e) {
123
- return false;
124
- }
125
- }
126
-
127
- /**
128
- * Get information about a specific channel.
129
- *
130
- * Returns metadata about the channel including whether it is
131
- * currently occupied and, for presence channels, the user count.
132
- *
133
- * @param string $channel The channel name to query
134
- * @return array Channel info ['occupied' => bool, 'user_count' => int|null]
135
- * Returns empty array on failure
136
- */
137
- public function channelInfo(string $channel): array
138
- {
139
- try {
140
- $info = $this->pusher->getChannelInfo($channel, [
141
- 'info' => 'user_count,subscription_count',
142
- ]);
143
-
144
- return [
145
- 'occupied' => $info->occupied ?? false,
146
- 'user_count' => $info->user_count ?? null,
147
- 'subscription_count' => $info->subscription_count ?? null,
148
- ];
149
- } catch (\Exception $e) {
150
- return [];
151
- }
152
- }
153
-
154
- /**
155
- * List all active (occupied) channels.
156
- *
157
- * Optionally filters channels by a name prefix. For example,
158
- * passing 'presence-' will return only active presence channels.
159
- *
160
- * @param string $prefix Optional channel name prefix filter
161
- * @return array List of active channel names
162
- */
163
- public function channels(string $prefix = ''): array
164
- {
165
- try {
166
- $params = [];
167
-
168
- if ($prefix !== '') {
169
- $params['filter_by_prefix'] = $prefix;
170
- }
171
-
172
- $result = $this->pusher->getChannels($params);
173
-
174
- if (isset($result->channels)) {
175
- return array_keys((array) $result->channels);
176
- }
177
-
178
- return [];
179
- } catch (\Exception $e) {
180
- return [];
181
- }
182
- }
183
-
184
- /**
185
- * Authenticate a private or presence channel subscription.
186
- *
187
- * This method should be called from your authentication endpoint
188
- * when a client attempts to subscribe to a private or presence channel.
189
- * Returns the authentication signature string that the client SDK expects.
190
- *
191
- * For presence channels, use presenceAuth() instead to include user data.
192
- *
193
- * @param string $channelName The channel being subscribed to
194
- * @param string $socketId The connecting socket's ID
195
- * @return string JSON-encoded authentication response
196
- */
197
- public function auth(string $channelName, string $socketId): string
198
- {
199
- try {
200
- return $this->pusher->authorizeChannel($channelName, $socketId);
201
- } catch (\Exception $e) {
202
- return json_encode(['error' => $e->getMessage()]);
203
- }
204
- }
205
-
206
- /**
207
- * Authenticate a presence channel subscription with user data.
208
- *
209
- * Similar to auth() but also attaches user identity and optional
210
- * metadata to the presence channel. This allows other subscribers
211
- * to see who is present in the channel.
212
- *
213
- * @param string $channelName The presence channel being subscribed to
214
- * @param string $socketId The connecting socket's ID
215
- * @param string $userId The unique identifier for the subscribing user
216
- * @param array $userInfo Optional additional user metadata (e.g., name, avatar)
217
- * @return string JSON-encoded authentication response with user data
218
- */
219
- public function presenceAuth(string $channelName, string $socketId, string $userId, array $userInfo = []): string
220
- {
221
- try {
222
- $presenceData = [
223
- 'user_id' => $userId,
224
- 'user_info' => $userInfo,
225
- ];
226
-
227
- return $this->pusher->authorizePresenceChannel($channelName, $socketId, $userId, $userInfo);
228
- } catch (\Exception $e) {
229
- return json_encode(['error' => $e->getMessage()]);
230
- }
231
- }
232
- }
1
+ <?php
2
+
3
+ namespace Src\Service;
4
+
5
+ use Pusher\Pusher;
6
+
7
+ /**
8
+ * Pusher Realtime Service
9
+ *
10
+ * Provides a clean interface for Pusher Channels — broadcasting events,
11
+ * authenticating private/presence channels, and querying channel state.
12
+ * Uses the pusher/pusher-php-server SDK. All configuration from $_ENV.
13
+ *
14
+ * Required environment variables:
15
+ * PUSHER_APP_ID — Your Pusher application ID
16
+ * PUSHER_APP_KEY — Your Pusher application key
17
+ * PUSHER_APP_SECRET — Your Pusher application secret
18
+ * PUSHER_CLUSTER — Pusher cluster region (e.g., 'eu', 'us2', 'ap1')
19
+ *
20
+ * @package Service
21
+ */
22
+ class PusherService
23
+ {
24
+ /**
25
+ * The Pusher SDK client instance.
26
+ *
27
+ * @var \Pusher\Pusher
28
+ */
29
+ private Pusher $pusher;
30
+
31
+ /**
32
+ * Create a new PusherService instance.
33
+ *
34
+ * Initializes the Pusher SDK client using credentials
35
+ * and cluster configuration from environment variables.
36
+ *
37
+ * @throws \Pusher\PusherException If credentials are invalid or missing
38
+ */
39
+ public function __construct()
40
+ {
41
+ $this->pusher = new Pusher(
42
+ $_ENV['PUSHER_APP_KEY'],
43
+ $_ENV['PUSHER_APP_SECRET'],
44
+ $_ENV['PUSHER_APP_ID'],
45
+ [
46
+ 'cluster' => $_ENV['PUSHER_CLUSTER'] ?? 'mt1',
47
+ 'useTLS' => true,
48
+ 'encrypted' => true,
49
+ ]
50
+ );
51
+ }
52
+
53
+ /**
54
+ * Broadcast an event to a single channel.
55
+ *
56
+ * Triggers an event on the specified channel, delivering
57
+ * the given data payload to all subscribers of that channel.
58
+ *
59
+ * Channel naming conventions:
60
+ * - Public channels: 'my-channel'
61
+ * - Private channels: 'private-my-channel'
62
+ * - Presence channels: 'presence-my-channel'
63
+ *
64
+ * @param string $channel The channel name to broadcast on
65
+ * @param string $event The event name to trigger
66
+ * @param array $data The event payload data
67
+ * @return bool True on success, false on failure
68
+ */
69
+ public function broadcast(string $channel, string $event, array $data): bool
70
+ {
71
+ try {
72
+ $response = $this->pusher->trigger($channel, $event, $data);
73
+
74
+ return (bool) $response;
75
+ } catch (\Exception $e) {
76
+ return false;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Broadcast an event to multiple channels simultaneously.
82
+ *
83
+ * Triggers the same event with the same payload across
84
+ * multiple channels in a single API call. Pusher limits
85
+ * this to a maximum of 100 channels per call.
86
+ *
87
+ * @param array $channels List of channel names (max 100)
88
+ * @param string $event The event name to trigger
89
+ * @param array $data The event payload data
90
+ * @return bool True on success, false on failure
91
+ */
92
+ public function broadcastToMany(array $channels, string $event, array $data): bool
93
+ {
94
+ try {
95
+ $response = $this->pusher->trigger($channels, $event, $data);
96
+
97
+ return (bool) $response;
98
+ } catch (\Exception $e) {
99
+ return false;
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Send an event to a specific user via their user channel.
105
+ *
106
+ * Uses Pusher's user event feature to deliver a message directly
107
+ * to a single authenticated user, regardless of which channels
108
+ * they are subscribed to. The user must have been authenticated
109
+ * with a user ID on the client side.
110
+ *
111
+ * @param string $userId The target user's unique identifier
112
+ * @param string $event The event name to trigger
113
+ * @param array $data The event payload data
114
+ * @return bool True on success, false on failure
115
+ */
116
+ public function toUser(string $userId, string $event, array $data): bool
117
+ {
118
+ try {
119
+ $response = $this->pusher->sendToUser($userId, $event, $data);
120
+
121
+ return (bool) $response;
122
+ } catch (\Exception $e) {
123
+ return false;
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Get information about a specific channel.
129
+ *
130
+ * Returns metadata about the channel including whether it is
131
+ * currently occupied and, for presence channels, the user count.
132
+ *
133
+ * @param string $channel The channel name to query
134
+ * @return array Channel info ['occupied' => bool, 'user_count' => int|null]
135
+ * Returns empty array on failure
136
+ */
137
+ public function channelInfo(string $channel): array
138
+ {
139
+ try {
140
+ $info = $this->pusher->getChannelInfo($channel, [
141
+ 'info' => 'user_count,subscription_count',
142
+ ]);
143
+
144
+ return [
145
+ 'occupied' => $info->occupied ?? false,
146
+ 'user_count' => $info->user_count ?? null,
147
+ 'subscription_count' => $info->subscription_count ?? null,
148
+ ];
149
+ } catch (\Exception $e) {
150
+ return [];
151
+ }
152
+ }
153
+
154
+ /**
155
+ * List all active (occupied) channels.
156
+ *
157
+ * Optionally filters channels by a name prefix. For example,
158
+ * passing 'presence-' will return only active presence channels.
159
+ *
160
+ * @param string $prefix Optional channel name prefix filter
161
+ * @return array List of active channel names
162
+ */
163
+ public function channels(string $prefix = ''): array
164
+ {
165
+ try {
166
+ $params = [];
167
+
168
+ if ($prefix !== '') {
169
+ $params['filter_by_prefix'] = $prefix;
170
+ }
171
+
172
+ $result = $this->pusher->getChannels($params);
173
+
174
+ if (isset($result->channels)) {
175
+ return array_keys((array) $result->channels);
176
+ }
177
+
178
+ return [];
179
+ } catch (\Exception $e) {
180
+ return [];
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Authenticate a private or presence channel subscription.
186
+ *
187
+ * This method should be called from your authentication endpoint
188
+ * when a client attempts to subscribe to a private or presence channel.
189
+ * Returns the authentication signature string that the client SDK expects.
190
+ *
191
+ * For presence channels, use presenceAuth() instead to include user data.
192
+ *
193
+ * @param string $channelName The channel being subscribed to
194
+ * @param string $socketId The connecting socket's ID
195
+ * @return string JSON-encoded authentication response
196
+ */
197
+ public function auth(string $channelName, string $socketId): string
198
+ {
199
+ try {
200
+ return $this->pusher->authorizeChannel($channelName, $socketId);
201
+ } catch (\Exception $e) {
202
+ return json_encode(['error' => $e->getMessage()]);
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Authenticate a presence channel subscription with user data.
208
+ *
209
+ * Similar to auth() but also attaches user identity and optional
210
+ * metadata to the presence channel. This allows other subscribers
211
+ * to see who is present in the channel.
212
+ *
213
+ * @param string $channelName The presence channel being subscribed to
214
+ * @param string $socketId The connecting socket's ID
215
+ * @param string $userId The unique identifier for the subscribing user
216
+ * @param array $userInfo Optional additional user metadata (e.g., name, avatar)
217
+ * @return string JSON-encoded authentication response with user data
218
+ */
219
+ public function presenceAuth(string $channelName, string $socketId, string $userId, array $userInfo = []): string
220
+ {
221
+ try {
222
+ $presenceData = [
223
+ 'user_id' => $userId,
224
+ 'user_info' => $userInfo,
225
+ ];
226
+
227
+ return $this->pusher->authorizePresenceChannel($channelName, $socketId, $userId, $userInfo);
228
+ } catch (\Exception $e) {
229
+ return json_encode(['error' => $e->getMessage()]);
230
+ }
231
+ }
232
+ }