Comments (9)
I see. If those are things you added then it's all good. As a matter of advice, you shouldn't use those variables directly, especially not in configuration.php, this file is loaded very early, you might be opening up your code for attacks instead of protecting it.
If you are interested to create a plugin for console that would be really great. We don't have a use for what you are trying to do but if you want to create the plugin we are most happy to make it available.
from joomlatools-console.
Hi @szepeviktor, thanks for the suggestion! Before I continue I'd like to point out that we only create issues for planned features or bug reports, as stated in our contributor guidelines. We're more than happy to discuss your ideas on our Gitter chat or mailing list first!
About your question, in theory it should be very easy to do this. Inside PHP's interactive shell you can load the Joomlatools Console's autoload.php file to get access to our bootstrapper class. With this you can start the Joomla application.
That said, Joomla doesn't seem to be able to start inside the interactive shell. Here's an example on our Vagrant box for a joomla site called foobar
:
[06:19 PM]-[vagrant@joomlatools]-[/var/www/foobar]
$ php -a
Interactive mode enabled
php > require_once('/home/vagrant/.composer/vendor/autoload.php');
php > Joomlatools\Console\Joomla\Bootstrapper::getApplication(getcwd());
php > echo JPATH_ROOT;
/var/www/foobar
php > echo \JFactory::getApplication()->getName();
PHP Warning: Uncaught Exception: Failed to start application in /var/www/foobar/libraries/src/Factory.php:137
If you can figure out why Joomla is unable to start in the interactive shell, it will be very easy to turn this into a single command.
Pull requests welcome!
from joomlatools-console.
@stevenrombauts Thank you.
Now there are two people lost in Joomla.
from joomlatools-console.
@stevenrombauts @szepeviktor This is because the application id you are using doesn't exists. You need to use a valid application id: 'site', 'administrator', 'cms', 'cli', 'deamon', 'web', 'webclient',
For a list of options see: https://github.com/joomla/joomla-cms/blob/6de2b00858e91bd64e7c410a6ed617d455f62d64/libraries/classmap.php#L27
For an example call see: https://github.com/joomla/joomla-cms/blob/staging/index.php#L46
You might also be able to directly instantiate the \Joomla\CMS\Application\CliApplication class: https://github.com/joomla/joomla-cms/blob/c9e45bb6f5718993f4bc0a36a23cccd3162b16cd/libraries/src/Application/CliApplication.php
from joomlatools-console.
Thank you!
echo \JFactory::getApplication('site')->getName();
works.
BTW this is my SEF route finder:
define('_JEXEC', 1);
if (empty($argv[1])) exit(1);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/';
if (file_exists(__DIR__ . '/defines.php'))
{
include_once __DIR__ . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', __DIR__);
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';
// Must be the 'site' application to get routes
$app = JFactory::getApplication('site');
$url = \JRoute::_($argv[1]);
printf("URL=/%s\n", $url);
from joomlatools-console.
@szepeviktor @stevenrombauts I think i see the issue. Think the problem lies in the call to getApplication() if this is hasn't been called before and it's called with no correct application name it will fail.
php > require_once('/home/vagrant/.composer/vendor/autoload.php');
php > Joomlatools\Console\Joomla\Bootstrapper::getApplication(getcwd());
php > echo \JFactory::getApplication('site')->getName();
Should work?
from joomlatools-console.
Yes, it actually does.
php > require '/home/muforum/vendor/autoload.php';
php > Joomlatools\Console\Joomla\Bootstrapper::getApplication(getcwd());
PHP Notice: Undefined index: REQUEST_METHOD in /home/muforum/public_html/server/configuration.php on line 14
PHP Notice: Undefined index: REQUEST_URI in /home/muforum/public_html/server/configuration.php on line 55
php > echo \JFactory::getApplication('site')->getName();
site
php >
Although it would be nice to have joomla eval 'echo JRoute::_("url-query-string");'
from joomlatools-console.
joomla eval would be possible, we would need to create an eval command that includes the code above. There is a whole section in the docs on how to create your own plugin: https://www.joomlatools.com/developer/tools/console/plugins/#creating-custom-plugins
Those notices are weird though, what is in your configuration.php file?
from joomlatools-console.
Those notices are weird though, what is in your configuration.php file?
That is a long story, I do not known Joomla (3.4.8) internals enough to protect it from attacks. There are some functions to log non-European HTTP/POST requests and block a kind of com_contenthistory-related attack and traffic from Tor network.
from joomlatools-console.
Related Issues (20)
- The option `--use-webroot-dir` is ignored when creating a Joomla site (site:create) HOT 3
- box php:use 7.4.4 HOT 1
- Enable Joomla 4 to be installed
- Make the console ubiqutious HOT 3
- Support symfony/console 5.x HOT 2
- Support for default overrides config file
- Merge joomlatools-plugin into core
- Fix vhost:alias command
- Remove support for Kodekit Platform
- Remove Joomlatools Platform support
- Remove support for Joomlatools Vagrant
- joomlatools language install failing HOT 1
- Console v2
- Add site:export and database:dump commands
- Load extra commands from home directory
- Parse environment variables in the config.yaml file
- Add chown support to site:download and site:create
- Update symlinker dependencies
- Unescaped spaces causes errors with site:download command
- Support for Joomla 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from joomlatools-console.