Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear path for Mobile_Detect.php #5

Closed
chaosarium opened this issue Jan 10, 2022 · 1 comment
Closed

Unclear path for Mobile_Detect.php #5

chaosarium opened this issue Jan 10, 2022 · 1 comment
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@chaosarium
Copy link

Describe the bug
Reading a text might result in this error:

[Mon Jan 10 17:40:52 2022] PHP 7.4.12 Development Server (http://localhost:9004) started
[Mon Jan 10 17:40:54 2022] [::1]:53495 Accepted
[Mon Jan 10 17:40:54 2022] [::1]:53495 [500]: GET /do_text.php?start=1 - require_once(): Failed opening required 'vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php' (include_path='.:/Applications/MAMP/bin/php/php7.4.12/lib/php') in /Users/username/vendor/hugofara/lwt/do_text.php on line 15
[Mon Jan 10 17:40:54 2022] [::1]:53495 Closing

To Reproduce
(I'm not sure if this is the proper way to set up lwt. But since MAMP doesn't come with composer, I followed this guide and put composer.phar in ~/

  1. composer require hugofara/lwt
  2. Start PHP development server from VSCode. Everything seems to work fine until making a request to do_text.php or do_test.php
  3. Read a text, which results in a blank web page

Expected behavior
lwt automatically finds the right Mobile_Detect.php.

Screenshots
Essentially blank web page:
image

Desktop (please complete the following information):

  • OS: MacOS 12.0.1
  • Browser: Safari
  • PHP 7.4.12
  • MySQL 5.7.32

Additional context
Specifying the absolute path to Mobile_Detect.php fixes the issue, but I'm sure this isn't the most elegant solution.

require_once '/Users/username/vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php'; // (was 'vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php';)

Since composer installs both mobiledetect/mobiledetectlib and hugofara/lwt in vendor/, this also works

require_once '../../mobiledetect/mobiledetectlib/Mobile_Detect.php'; // (was 'vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php';)
@HugoFara HugoFara self-assigned this Jan 10, 2022
@HugoFara HugoFara added bug Something isn't working documentation Improvements or additions to documentation labels Jan 10, 2022
@HugoFara
Copy link
Owner

Hello!

Apparently I went a bit too fast with issue #4 . Composer isn't guilty here: the command I suggest in the README (composer require) is wrong.

Problem

composer require is usually used for packages you want to include in another project (API for instance). However, LWT is an application. It installs LWT in the vendor/ folder, which breaks all paths.

Solution

Use composer create-project hugofara/lwt. It will create a folder with the same organization is in the git.

In the future

With v2.1.0, I have more or less finished reorganizing the code. Now I will continue developing tests, so that I won't miss this kind of obvious issue. Until then, thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants