Learning with Texts - Fork
2.10.0-fork
Learn foreign languages with texts
|
This guide is mainly aimed at developers, but it can give useful insights on how LWT is structured, which could help with debugging. The first step you need to take is to clone LWT from the official GitHub repository (HugoFara/lwt).
Getting Composer is required if you want to edit LWT on the server side, but it will also be useful to edit JS and CSS code, so it is highly recommended. Composer is a lightweight dependency manager that does not need a server to run.
Once Composer is ready, go to the lwt folder (most likely lwt/
), and type
This will automatically download all the required dependencies.
Themes are stored at src/themes/
. If you want to create a new theme, simply add it to a subfolder. You can also edit existing themes.
To apply the changes you made to a theme, run
This command will minify all CSS and JS.
Alternatively, you can run
It minifies only CSS.
You may not want to see your code minified, so you can use
It has the same effect as copying the folder src/themes/
to themes/
. WARNING: It can break your relative paths!
We support a smart minifying system: relative paths are automatically adapted to point to the previous location while minifying only. As a consequence:
css/images/
in your theme.src/themes/mytheme/
, you should use the path ../../../css/theimage
../myimage
.When debugging your theme, files are simply copied to the themes/
folder, which can break the path to files in css/
.
That's not a problem at all. When LWT looks for a file that should be contained in src/themes/{{The Theme}}/
, it checks if the file exists. If not, it goes to css/
and tries to get the same file. With this system, your themes do not need to have the same files as src/css/
.
As with themes, LWT minifies JS code for a better user experience. Please refer to the previous section for detailed explanations; this section will only go through import points.
Clear code is stored at src/js/
. Once again, the actual code used by LWT should be at js/
. After you have done any modification, either run composer minify
or php -r "require 'src/php/minifier.php'; minifyAllJS();"
.
To copy code in a non-obfuscated form, run composer no-minify
or replace the content of js/
with src/js/
.
The PHP codebase is not yet well structured, but here is a general organization:
do_text.php
, do_test.php
, etc...)inc/
("include") folder.src/php/
.It is highly advised to test your code. Tests should be wrote under tests/
. We use PHP Unit for testing.
To run all tests:
composer test
Alternatively:
./vendor/bin/phpunit
We use Psalm to find code flaws and inconsistencies. Use ./vendor/bin/psalm
.
You can configure the reporting level in psalm.xml
.
Nobody likes to debug unreadable code. A good way to avoid thinking about it is to include phpcs directly in your IDE. You can also download it and run it regularly on your code.
You can run it through composer. Use php ./vendor/bin/squizlabs/phpcs.phar [filename]
to see style violations on a file. You can fix them using
Starting from 2.9.0-fork, LWT provides a RESTful API. The main handler for the API is api.php
. You can find a more exhaustive API documentation at api.md.
If you plan to develop the API, please follow the RESTful standards. To debug:
npm install
in the main LWT folder.npm test
to test the API.To regenerate all PHP and Markdown documentation, use composer doc
. For the JS documentation, you need NPM. Use ./node_modules/.bin/jsdoc -c jsdoc.json
.
The documentation is split across Markdown (.md
) files in docs/
. Then, those files are requested by info.php
. The final version is info.html
, which contains all files.
To regenerate info.hml
, run composer info.html
.
Code documentation (everything under docs/html/
and docs/php/
) is automatically generated. If you see an error, the PHP code is most likely at fault. However, don't hesitate to signal the issue.
Currently, the PHP documentation is generated two times:
doxygen Doxyfile
to regenerate it), it generates documentation for MarkDown and PHP files. It will be removed in LWT 3.0.0.php tools/phpDocumentor
if installed with Phive.Code documentation for JavaScript is available at docs/js/
is is generated thourgh JSDoc. The JSDoc configuration file is jsdoc.json
.
LWT-fork follows a strict procedure for new versions. This section is mainly intended for the maintainers, but feel free to take a peak at it.
The steps to publish a new version are:
inc/kernel_utility.php
, update LWT_APP_VERSION
and LWT_RELEASE_DATE
.PROJECT_NUMBER
in Doxyfile
to the latest release number.composer doc
.git commit -m "Regenerates documentation for release []."
git tag -a [release number]
and push the changes.This is an open-source project. It means that anyone can contribute, but nobody gets paid for improving it. Dropping a star, leaving a comment, or posting an issue is essential because the only reward developers get from time spent on LWT is the opportunity to discuss with users.
LWT is a non-profitable piece of software, so we won't have much time or money to advertise it. If you enjoy LWT and want to see it grow, share it!
Either go to the forum of the official LWT version, or come and discuss on the community version.
LWT is hosted on OpenCollective, you can support the development of the app at https://opencollective.com/lwt-community.
Thanks for your interest in contributing!