├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── config.yml └── workflows │ ├── php-cs-fixer.yml │ └── update-changelog.yml ├── .gitignore ├── .php_cs.cache ├── .php_cs.dist ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── codeception.yml ├── composer.json ├── composer.lock └── src ├── CraftRay.php ├── OriginFactory.php ├── Ray.php ├── icon.svg ├── models └── Settings.php ├── templates └── settings.twig └── twigextensions ├── RayNode.php ├── RayTokenParser.php ├── RayTwigExtension.php └── RayVariable.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: spatie 2 | custom: https://spatie.be/open-source/support-us 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve Ray 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Versions** 14 | Ray version (you can see this in "About Ray"): 15 | 16 | You can use `composer show` to get the version numbers of: 17 | - spatie/craft-ray package version: 18 | 19 | PHP version: 20 | Laravel version (if applicable): 21 | 22 | **To Reproduce** 23 | Steps to reproduce the behavior: 24 | 1. Go to '...' 25 | 2. Click on '....' 26 | 3. Scroll down to '....' 27 | 4. See error 28 | 29 | **Expected behavior** 30 | A clear and concise description of what you expected to happen. 31 | 32 | **Screenshots** 33 | If applicable, add screenshots to help explain your problem. 34 | 35 | **Desktop (please complete the following information):** 36 | - OS: [e.g. macOS] 37 | - Version [e.g. 22] 38 | 39 | **Additional context** 40 | Add any other context about the problem here. 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Ask a Question 4 | url: https://github.com/spatie/craft-ray/discussions/new?category=q-a 5 | about: Ask the community for help 6 | - name: Feature Request 7 | url: https://github.com/spatie/craft-ray/discussions/new?category=ideas 8 | about: Share ideas for new features 9 | - name: Bug Report 10 | url: https://github.com/spatie/craft-ray/issues/new 11 | about: Report a reproducable bug 12 | -------------------------------------------------------------------------------- /.github/workflows/php-cs-fixer.yml: -------------------------------------------------------------------------------- 1 | name: Check & fix styling 2 | 3 | on: [push] 4 | 5 | jobs: 6 | php-cs-fixer: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v2 12 | with: 13 | ref: ${{ github.head_ref }} 14 | 15 | - name: Run PHP CS Fixer 16 | uses: docker://oskarstark/php-cs-fixer-ga 17 | with: 18 | args: --config=.php_cs.dist --allow-risky=yes 19 | 20 | - name: Commit changes 21 | uses: stefanzweifel/git-auto-commit-action@v4 22 | with: 23 | commit_message: Fix styling 24 | -------------------------------------------------------------------------------- /.github/workflows/update-changelog.yml: -------------------------------------------------------------------------------- 1 | name: "Update Changelog" 2 | 3 | on: 4 | release: 5 | types: [released] 6 | 7 | jobs: 8 | update: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v2 14 | with: 15 | ref: main 16 | 17 | - name: Update Changelog 18 | uses: stefanzweifel/changelog-updater-action@v1 19 | with: 20 | latest-version: ${{ github.event.release.name }} 21 | release-notes: ${{ github.event.release.body }} 22 | 23 | - name: Commit updated CHANGELOG 24 | uses: stefanzweifel/git-auto-commit-action@v4 25 | with: 26 | branch: main 27 | commit_message: Update CHANGELOG 28 | file_pattern: CHANGELOG.md 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # CRAFT ENVIRONMENT 2 | .env.php 3 | .env.sh 4 | .env 5 | 6 | # COMPOSER 7 | /vendor 8 | 9 | # BUILD FILES 10 | /bower_components/* 11 | /node_modules/* 12 | /build/* 13 | /yarn-error.log 14 | 15 | # MISC FILES 16 | .cache 17 | .DS_Store 18 | .idea 19 | .project 20 | .settings 21 | *.esproj 22 | *.sublime-workspace 23 | *.sublime-project 24 | *.tmproj 25 | *.tmproject 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | config.codekit3 32 | prepros-6.config 33 | -------------------------------------------------------------------------------- /.php_cs.cache: -------------------------------------------------------------------------------- 1 | {"php":"8.0.3","version":"2.18.5","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sortAlgorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline_array":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":["method"]},"single_trait_insert_per_statement":true},"hashes":{"src\/OriginFactory.php":2587249863,"src\/Ray.php":4053202177,"src\/CraftRay.php":3042012578,"src\/models\/Settings.php":2140290310,"src\/twigextensions\/RayTokenParser.php":1195122668,"src\/twigextensions\/RayTwigExtension.php":2726561284,"src\/twigextensions\/RayNode.php":3492123143,"src\/twigextensions\/RayVariable.php":1953657964,"tests\/unit\/ExampleUnitTest.php":1891012367,"tests\/unit\/_bootstrap.php":52093902,"tests\/_craft\/config\/routes.php":2102360284,"tests\/_craft\/config\/db.php":2844373464,"tests\/_craft\/config\/test.php":2374578403,"tests\/_craft\/config\/general.php":1363230597,"tests\/_support\/FunctionalTester.php":134463257,"tests\/_support\/Helper\/Unit.php":4000112851,"tests\/_support\/Helper\/Functional.php":176247954,"tests\/_support\/UnitTester.php":112403609,"tests\/_bootstrap.php":230058715,"tests\/functional\/_bootstrap.php":52093902,"tests\/functional\/ExampleFunctionalCest.php":1212287981}} -------------------------------------------------------------------------------- /.php_cs.dist: -------------------------------------------------------------------------------- 1 | in([ 5 | __DIR__ . '/src', 6 | __DIR__ . '/tests', 7 | ]) 8 | ->name('*.php') 9 | ->notName('*.twig') 10 | ->ignoreDotFiles(true) 11 | ->ignoreVCS(true); 12 | 13 | return PhpCsFixer\Config::create() 14 | ->setRules([ 15 | '@PSR2' => true, 16 | 'array_syntax' => ['syntax' => 'short'], 17 | 'ordered_imports' => ['sortAlgorithm' => 'alpha'], 18 | 'no_unused_imports' => true, 19 | 'not_operator_with_successor_space' => true, 20 | 'trailing_comma_in_multiline_array' => true, 21 | 'phpdoc_scalar' => true, 22 | 'unary_operator_spaces' => true, 23 | 'binary_operator_spaces' => true, 24 | 'blank_line_before_statement' => [ 25 | 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], 26 | ], 27 | 'phpdoc_single_line_var_spacing' => true, 28 | 'phpdoc_var_without_name' => true, 29 | 'class_attributes_separation' => [ 30 | 'elements' => [ 31 | 'method', 32 | ], 33 | ], 34 | 'method_argument_space' => [ 35 | 'on_multiline' => 'ensure_fully_multiline', 36 | 'keep_multiple_spaces_after_comma' => true, 37 | ], 38 | 'single_trait_insert_per_statement' => true, 39 | ]) 40 | ->setFinder($finder); 41 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # ray Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). 6 | 7 | ## 2.1.1 - 2024-03-21 8 | 9 | - Fix environment variables in settings not working 10 | 11 | **Full Changelog**: https://github.com/spatie/craft-ray/compare/2.1.0...2.1.1 12 | 13 | ## 2.1.0 - 2024-03-21 14 | 15 | - Allow Craft v5 16 | 17 | **Full Changelog**: https://github.com/spatie/craft-ray/compare/2.0...2.1.0 18 | 19 | ## 2.0 - 2022-03-17 20 | 21 | - Add compatibility with Craft 4 22 | 23 | **Full Changelog**: https://github.com/spatie/craft-ray/compare/1.1.5...2.0 24 | 25 | ## 1.1.5 - 2021-04-16 26 | 27 | ### Fixed 28 | 29 | - Fixed an issue where only the last Ray call in a request was output to the screen 30 | 31 | ## 1.1.4 - 2021-03-05 32 | 33 | ### Fixed 34 | 35 | - Fixed an issue where passing multiple parameters to the Twig function would only result in one Ray entry 36 | - Fixed an issue where host & port setting wouldn't end up correctly in the Ray client 37 | 38 | ## 1.1.3 - 2021-02-12 39 | 40 | ### Added 41 | 42 | - Fix enabled state 43 | 44 | ## 1.1.2 - 2021-02-12 45 | 46 | ### Added 47 | 48 | - Allow PHP 7.4 49 | 50 | ## 1.1.1 - 2021-01-20 51 | 52 | ### Added 53 | 54 | - Allow PHP 7.3 55 | 56 | ## 1.0.1 - 2021-01-20 57 | 58 | ### Fixed 59 | 60 | - Fix version constraint 61 | 62 | ## 1.0.0 - 2021-01-20 63 | 64 | ### Added 65 | 66 | - Initial release 67 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Spatie bvba 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [](https://supportukrainenow.org) 3 | 4 | # Debug with Ray to fix problems faster 5 | 6 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/craft-ray.svg?style=flat-square)](https://packagist.org/packages/spatie/craft-ray) 7 | ![Tests](https://github.com/spatie/craft-ray/workflows/Tests/badge.svg) 8 | [![Total Downloads](https://img.shields.io/packagist/dt/spatie/craft-ray.svg?style=flat-square)](https://packagist.org/packages/spatie/craft-ray) 9 | 10 | This package can be installed in any PHP application to send messages to [the Ray app](https://myray.app). 11 | 12 | ## Documentation 13 | 14 | You can find the full documentation on [our documentation site](https://spatie.be/docs/ray). 15 | 16 | ## Changelog 17 | 18 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 19 | 20 | ## Contributing 21 | 22 | Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details. 23 | 24 | ## Security Vulnerabilities 25 | 26 | Please review [our security policy](../../security/policy) on how to report security vulnerabilities. 27 | 28 | ## Credits 29 | 30 | - [Rias Van der Veken](https://github.com/riasvdv) 31 | - [All Contributors](../../contributors) 32 | 33 | ## License 34 | 35 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 36 | -------------------------------------------------------------------------------- /codeception.yml: -------------------------------------------------------------------------------- 1 | actor: Tester 2 | paths: 3 | tests: tests 4 | log: tests/_output 5 | data: tests/_data 6 | support: tests/_support 7 | envs: tests/_envs 8 | settings: 9 | bootstrap: _bootstrap.php 10 | coverage: 11 | enabled: true 12 | include: 13 | - src/* 14 | exclude: 15 | - src/etc/* 16 | - src/migrations/* 17 | - src/templates/* 18 | - src/translations/* 19 | - src/web/assets/* 20 | - docs/* 21 | - templates/* 22 | - tests/* 23 | - vendor/* 24 | params: 25 | - tests/.env 26 | modules: 27 | config: 28 | \craft\test\Craft: 29 | configFile: 'tests/_craft/config/test.php' 30 | entryUrl: 'https://test.craftcms.test/index.php' 31 | projectConfig: {} 32 | migrations: [] 33 | plugins: 34 | ray: 35 | class: '\spatiecraftray\ray\Ray' 36 | handle: ray 37 | cleanup: true 38 | transaction: true 39 | dbSetup: {clean: true, setupCraft: true} 40 | fullMock: false 41 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spatie/craft-ray", 3 | "description": "Easily debug CraftCMS projects", 4 | "type": "craft-plugin", 5 | "keywords": [ 6 | "craft", 7 | "cms", 8 | "craftcms", 9 | "craft-plugin", 10 | "ray" 11 | ], 12 | "support": { 13 | "docs": "https://github.com/spatie/craft-ray/blob/master/README.md", 14 | "issues": "https://github.com/spatie/craft-ray/issues" 15 | }, 16 | "license": "MIT", 17 | "authors": [ 18 | { 19 | "name": "Spatie", 20 | "homepage": "https://spatie.be" 21 | } 22 | ], 23 | "require": { 24 | "php": "^8.0", 25 | "craftcms/cms": "^4.0|^5.0", 26 | "spatie/ray": "^1.34", 27 | "spatie/yii-ray": "^1.2" 28 | }, 29 | "require-dev": { 30 | "vlucas/phpdotenv": "^3.0" 31 | }, 32 | "autoload": { 33 | "psr-4": { 34 | "Spatie\\CraftRay\\": "src/" 35 | } 36 | }, 37 | "extra": { 38 | "name": "Ray", 39 | "handle": "craft-ray", 40 | "developer": "Spatie", 41 | "developerUrl": "https://spatie.be", 42 | "documentationUrl": "https://github.com/spatie/craft-ray/blob/master/README.md", 43 | "changelogUrl": "https://raw.githubusercontent.com/spatie/craft-ray/master/CHANGELOG.md", 44 | "class": "Spatie\\CraftRay\\CraftRay" 45 | }, 46 | "minimum-stability": "dev", 47 | "prefer-stable": true, 48 | "config": { 49 | "allow-plugins": { 50 | "yiisoft/yii2-composer": true, 51 | "craftcms/plugin-installer": true 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/CraftRay.php: -------------------------------------------------------------------------------- 1 | view->registerTwigExtension(new RayTwigExtension()); 37 | 38 | Yii::$container->set(Ray::class, function () { 39 | $craftRaySettings = CraftRay::getInstance()->getSettings(); 40 | 41 | $settings = new \Spatie\Ray\Settings\Settings([ 42 | 'enable' => App::parseBooleanEnv($craftRaySettings->enable), 43 | 'host' => App::parseEnv($craftRaySettings->host), 44 | 'port' => (int) App::parseEnv($craftRaySettings->port), 45 | 'remote_path' => App::parseEnv($craftRaySettings->remote_path), 46 | 'local_path' => App::parseEnv($craftRaySettings->local_path), 47 | ]); 48 | 49 | $ray = new Ray($settings); 50 | 51 | if (! $settings->enable) { 52 | $ray->disable(); 53 | } 54 | 55 | return $ray; 56 | }); 57 | 58 | Payload::$originFactoryClass = OriginFactory::class; 59 | } 60 | 61 | // Protected Methods 62 | // ========================================================================= 63 | 64 | /** 65 | * @inheritdoc 66 | */ 67 | protected function createSettingsModel(): ?\craft\base\Model 68 | { 69 | return new Settings(); 70 | } 71 | 72 | /** 73 | * @inheritdoc 74 | */ 75 | protected function settingsHtml(): ?string 76 | { 77 | return Craft::$app->view->renderTemplate( 78 | 'craft-ray/settings', 79 | [ 80 | 'settings' => $this->getSettings(), 81 | ] 82 | ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/OriginFactory.php: -------------------------------------------------------------------------------- 1 | getFrame(); 21 | 22 | return new Origin( 23 | $frame->file ?? null, 24 | $frame->lineNumber ?? null, 25 | ); 26 | } 27 | 28 | protected function getFrame(): ?Frame 29 | { 30 | $frames = (new Collection(Backtrace::create()->frames()))->reverse(); 31 | 32 | $indexOfRay = $frames->search(function (Frame $frame) { 33 | if ($frame->class === Ray::class) { 34 | return true; 35 | } 36 | 37 | if (str_starts_with($frame->file, __DIR__)) { 38 | return true; 39 | } 40 | 41 | return false; 42 | }); 43 | 44 | /** @var Frame|null $rayFrame */ 45 | $rayFrame = $frames[$indexOfRay] ?? null; 46 | 47 | if (! $rayFrame) { 48 | return null; 49 | } 50 | 51 | /** @var Frame|null $foundFrame */ 52 | $originFrame = $frames[$indexOfRay + 1] ?? null; 53 | 54 | if ($originFrame && str_ends_with($originFrame->file, Ray::makePathOsSafe('ray/src/helpers.php'))) { 55 | $originFrame = $frames[$indexOfRay + 2] ?? null; 56 | } 57 | 58 | if (is_null($originFrame->class) && $originFrame->method === 'call_user_func') { 59 | $originFrame = $frames[$indexOfRay + 2] ?? null; 60 | } 61 | 62 | 63 | if (str_starts_with($originFrame->file, Craft::$app->getRuntimePath() . '/compiled_templates')) { 64 | return $this->replaceCompiledTemplatePathWithOriginalTemplatePath($originFrame); 65 | } 66 | 67 | if ($originFrame->class === Event::class) { 68 | return $this->findFrameForEvent($frames); 69 | } 70 | 71 | return $originFrame; 72 | } 73 | 74 | protected function findFrameForEvent(Collection $frames): ?Frame 75 | { 76 | $indexOfComponentCall = $frames 77 | ->search(function (Frame $frame) { 78 | return $frame->class === Component::class; 79 | }); 80 | 81 | /** @var Frame $foundFrame */ 82 | $foundFrame = $frames[$indexOfComponentCall + 1]; 83 | 84 | return $foundFrame ?? null; 85 | } 86 | 87 | private function replaceCompiledTemplatePathWithOriginalTemplatePath(Frame $frame): Frame 88 | { 89 | if (! file_exists($frame->file)) { 90 | return $frame; 91 | } 92 | 93 | $fileContents = file_get_contents($frame->file); 94 | $class = trim(StringHelper::between($fileContents, 'class ', 'extends')); 95 | 96 | /** @var \Twig\Template $template */ 97 | $template = new $class(Craft::$app->getView()->createTwig()); 98 | 99 | $originalViewPath = $template->getSourceContext()->getPath(); 100 | 101 | if (! file_exists($originalViewPath)) { 102 | return $frame; 103 | } 104 | 105 | $frame->file = $originalViewPath; 106 | $frame->lineNumber = 1; 107 | 108 | return $frame; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Ray.php: -------------------------------------------------------------------------------- 1 | enabled()) { 27 | return $this; 28 | } 29 | 30 | $meta = [ 31 | 'craft_version' => Craft::getVersion(), 32 | ]; 33 | 34 | if (class_exists(InstalledVersions::class)) { 35 | $meta['craft_ray_package_version'] = InstalledVersions::getVersion('spatie/craft-ray'); 36 | } 37 | 38 | return BaseRay::sendRequest($payloads, $meta); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 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 | -------------------------------------------------------------------------------- /src/models/Settings.php: -------------------------------------------------------------------------------- 1 | [ 45 | 'class' => EnvAttributeParserBehavior::class, 46 | 'attributes' => ['enable', 'host', 'port', 'remote_path', 'local_path'], 47 | ], 48 | ]; 49 | } 50 | 51 | /** 52 | * @inheritdoc 53 | */ 54 | public function rules(): array 55 | { 56 | return [ 57 | [['host', 'port'], 'required'], 58 | ['enable', 'boolean'], 59 | ]; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/templates/settings.twig: -------------------------------------------------------------------------------- 1 | {% import "_includes/forms" as forms %} 2 | 3 | {{ forms.lightswitchField({ 4 | label: "Enable"|t('craft-ray'), 5 | instructions: "Whether data should be sent to Ray."|t('craft-ray'), 6 | id: 'enable', 7 | name: 'enable', 8 | on: settings.enable, 9 | errors: settings.getErrors('enable') 10 | }) }} 11 | 12 | {{ forms.autosuggestField({ 13 | label: "Host"|t('craft-ray'), 14 | instructions: "The host used to communicate with the Ray app."|t('craft-ray'), 15 | id: 'host', 16 | name: 'host', 17 | value: settings.host, 18 | suggestEnvVars: true, 19 | errors: settings.getErrors('host') 20 | }) }} 21 | 22 | {{ forms.autosuggestField({ 23 | label: "Port"|t('craft-ray'), 24 | instructions: "The port number used to communicate with the Ray app."|t('craft-ray'), 25 | id: 'port', 26 | name: 'port', 27 | value: settings.port, 28 | suggestEnvVars: true, 29 | errors: settings.getErrors('port') 30 | }) }} 31 | 32 | {{ forms.autosuggestField({ 33 | label: "Remote path"|t('craft-ray'), 34 | instructions: "Absolute base path for your sites or projects in Homestead, Vagrant, Docker, or another remote development server."|t('craft-ray'), 35 | id: 'remote_path', 36 | name: 'remote_path', 37 | value: settings.remote_path, 38 | suggestEnvVars: true, 39 | errors: settings.getErrors('remote_path') 40 | }) }} 41 | 42 | {{ forms.autosuggestField({ 43 | label: "Local path"|t('craft-ray'), 44 | instructions: "Absolute base path for your sites or projects on your local computer where your IDE or code editor is running on."|t('craft-ray'), 45 | id: 'local_path', 46 | name: 'local_path', 47 | value: settings.local_path, 48 | suggestEnvVars: true, 49 | errors: settings.getErrors('local_path') 50 | }) }} 51 | -------------------------------------------------------------------------------- /src/twigextensions/RayNode.php: -------------------------------------------------------------------------------- 1 | addDebugInfo($this); 16 | 17 | $compiler 18 | ->write('ray(') 19 | ->subcompile($this->getNode('var')) 20 | ->raw(");\n"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/twigextensions/RayTokenParser.php: -------------------------------------------------------------------------------- 1 | getLine(); 13 | 14 | $parser = $this->parser; 15 | $stream = $parser->getStream(); 16 | 17 | $nodes = [ 18 | 'var' => $parser->getExpressionParser()->parseExpression(), 19 | ]; 20 | 21 | $stream->expect(Token::BLOCK_END_TYPE); 22 | 23 | return new RayNode($nodes, [], $lineno, $this->getTag()); 24 | } 25 | 26 | public function getTag() 27 | { 28 | return 'ray'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/twigextensions/RayTwigExtension.php: -------------------------------------------------------------------------------- 1 | new RayVariable, 71 | ]; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/twigextensions/RayVariable.php: -------------------------------------------------------------------------------- 1 | $name(); 11 | } 12 | 13 | return ray()->$name($arguments); 14 | } 15 | } 16 | --------------------------------------------------------------------------------