PhpStorm - undefined class in Joomla project - joomla

I want to use PhpStorm on Joomla project but I can not use "Go to Class Declaration" (Ctrl+B) on main Joomla classes. For example JFactory::getApplication().
But with my own functions in custom plugin that option works great.
What it can be wrong there?
I have Joomla support plugin.
I have docblock plugin.
I tried invalidate caches.

Legacy code
You only need that to work on legacy code. With the introduction of namespaces, most classnames have changed.
JFactory is a now non-existent class - it has been removed from the core. For compatibility's sake, a class alias is provided at runtime, so PHP can find the new class instead. PhpStorm (and other IDEs) don't know about those aliases (there are a lot more of them).
Stubbing
To solve the problem, Joomla provides a stub, that tells the IDE where to find the new class. Just run
$ php build/stubGenerator.php
This will generate a stubs.php file in your project's root directory with the proper information.
New code
For new code, don't use those old classnames - use their new name instead. The new classnames make it much more likely, that your new code will run on Joomla! 4.0.

Related

How to get IDE to recognize methods used by Laravel Routes? (PhpStorm)

PhpStorm uses yellow font for method names if it detects that the method is in use elsewhere in the app.
It uses a grey font for unused methods.
This is really helpful for identifying stale code.
But PhpStorm doesn't recognize my methods that I am using in the /routes directory since they are called magically from a string.
For example, I am only using the sendPayout method in /routes, but the chargeCustomer is called directly from within another method.
For example, this line in /routes/web.php should ideally force the sendPayout method shown in the screenshot to appear in yellow font.
Route::post('/api/send-offer','StripeController#sendPayout');
Is there any way to get PhpStorm to recognize this, either by changing settings or using a certain plugin?
I am using PhpStorm 2019.3.1, MacOS Catalina version 10.15.2, and Laravel 5.8. I already have the Laravel plugin installed to PhpStorm.
Per #LazyOne's comments, the plugin "Laravel Idea" does solve the recognization issue for all Symfony and Laravel methods that aren't already picked up by PhpStorm's default. I definitely recommend this plugin now that I am using it.
There is special file for this called '.phpstorm.meta'. So you can "map" methods. Read more here: https://www.jetbrains.com/help/phpstorm/ide-advanced-metadata.html

How to customise a Laravel application

I'm total newbie with Laravel, so the question might not be the most intelligent, be gentle, please.
I'd like to use an Open Source application made with Laravel. However, the application does not fully suit my needs, hence some customization is needed.
Naturally, I don't what to change the application files and also want to keep all my files separated.
In other PHP-based applications there are typically methods to customise the app without touching any other code. Also, it is possible to have own code nicely in one place. For instance, Wordpress has a theme concept, child theme concept, plugins and hooks in code (filters and actions). In Magento we have a simple method of overriding a core file by copying it to local code pool, as well as a more sophisticated dependency injection, which allows to override any class anywhere.
I've been trying to understand what is the correct way to customise a Laravel application in such a way, that my own modifications are separated from the base application and e.g. updating the base is possible.
Please guide me, or give pointers on how to do this.
Sounds like Packages might be your best option.
https://laravel.com/docs/master/packages
They let you customize very much in your application without touching other parts of the code, as well as keeping it separated from the other parts of the application.
Here's a getting started guide on packages:
https://medium.com/#lasselehtinen/getting-started-on-laravel-package-development-a62110c58ba1

Xcode6 how to set class prefix when create a new project?

Unlike Xcode5, when create new project, there is not a input field for class prefix.
Did Apple abandon it?
Yes, Apple abandoned it.
After much deliberation, engineering has removed this feature.
This was removed intentionally. We are no longer encouraging the use of prefixes for app code, and for frameworks, you can create a prefix in the Project Inspector after creating the project.
Additional information can be found in this article.

joomla 3 vs 2.5 extension development differences

I am joomla user and I have created some extensions's and templates for joomla 2.5, but now I upgraded to joomla 3 because of bootstrap framework and responsive templates. I need your help here:
How to update joomla 2.5 extension to work with joomla 3 and be responsive?
I googled for a wile and couldn't find any answer about "extensions".
It's a big question, but here are some baseline steps.
First, make sure that your 2.5 code is clean. That is if you are still using any classes that were deprecated in 2.5 first go ahead and update them in your 2.5 version or else do that first in your 3 version. If you aren't logging deprecated classes you should do so to make sure you don't miss any. In particular you want to get rid of JRequest and look for any methods you might have extended that themselves extended JObject and make sure you are not relying on those methods. Also, you need to make sure you have changed any extends JModel to extends JModelLegacy (and similar for JView and JController). Depending on the complexity of your outputs you can likely follow the core code as a model for your administrator layouts. For the front endin my experience you are mainly just changing layout files to use the newer classes and ids.
If you use the Component Creator to develop your component framework you can specify if you want to build Joomla 2.5 or Joomla 3.0 compatible code.
Since 2.5 is the current LTS version until 3.5; the majority of the core changes are deprecated versus being completely removed. Meaning you can still use them and there are overall not many things required to migrate a 2.5 component, for now. I would definitely read through the walk through provided by Soren, but here are the three "major" required changes to get a 2.5 component working on 3.1 and above Joomla... with caveats of course! :D
1) Make sure all your view classes extend JViewLegacy
2) Make sure your primary controller extends JControllerLegacy instead of JController
3) Make sure your primary component entry point (my_component_name.php file in component root) use JControllerLegacy::getInstance('my_component_name') instead of JController::getInstance('my_component_name')

Smarty integration into the CodeIgniter framework

A Little Background Information:
I've been looking at a few PHP framework recently, and it came down to two. The Zend Framework or CodeIgniter.
I prefer CodeIgniter, because of its simple design. It's very bare bone, and it is just kept simple. The thing I don't like though is the weak template system. The template system is important for me, because I will be working with another designer. Being able to give him a good template system is a big plus.
Zend was the second choice, because of the better template system that is built in. Zend is a different beast though compared to CodeIgniter. It emphasis "loose coupling between modules", but is a bigger framework. I don't like to feel like I have many things running under the hood that I never use. That is unnecessary overhead in my opinion, so I thought about putting a template system into CodeIgniter: Smarty.
Question(s): How easy/hard is the process to integrate Smarty into CodeIgniter? From my initial scan of the CodeIgniter documentation, I can see that the layout of the framework is easy enough to understand, and I anticipate no problems. I want to know if anyone has used it before, and therefore are aware of any "gotchas" you my have experienced that is going to make this harder than it should be or impossible to pull off. I also want to know if this is a good thing to do at all. Is the template system in CodeIgniter enough for normal use? Are there any other template modules that are good for CodeIgniter aside from Smarty? I better off with Zend Framework? Is any wheel being invented here?
Sorry to resurrect an old question - but none of the answers have been flagged as "accepted" yet.
There's a library called "template" that does a great job of allowing you to use just about any template parser you want:
Template CI Library - V1.4.1
The syntax is pretty easy for integrating into your CI application and the smarty integration spot on.
Slightly OT, hope you don't mind...
I'm a Zend Framework user and I think it's worth saying that the loose coupling means you don't need to include any files you're not actively using. Hopefully this negates your concern about unnecessary overhead.
With the layouts stuff added in a recent release of ZF, its templating is really hard to fault... and it's completely pluggable as Favio mentions. The more I use ZF, the more I like it; they do things the way I would do them!
I did a quick google search and found the following:
http://devcha.blogspot.com/2007/12/smarty-as-template-engine-in-code.html
http://codeigniter.com/forums/viewthread/67127/
If the designer is not familiar with Smarty, I think it's almost the same as if you use the existing CodeIgniter templating system (which leaves everything to PHP actually). It also depends on the complexity of the project at hand.
You can also hook Smarty with Zend Framework. It's more complex than with CodeIgniter, but there's already a primer on how to do exactly that in the ZF documentation. http://framework.zend.com/manual/en/zend.view.scripts.html Plus lots of tutorials on the net.
In my opinion it's almost the same, you can use pure PHP or Smarty as your template "engine", so it depends on the project. Also, compare a developer who has extensive experience and already has a library of view helpers so she uses pure PHP, versus a designer who doesn't know anything about PHP, but has extensive experience with Smarty. Sometimes decisions have to be based on who is going to do what.
Check out this custom CodeIgniter templating library. I've already used it on several projects and it is easy to use. I know this post is late but it's worth checking out.
It doesn't appear there has been an answer selected for this question nor has an up-to-date solution been given to work with the latest version of Codeigniter (2.0) and the latest version of Smarty (3.0.5).
This library allows you to use Smarty 3 with Codeigniter 2.0 so you can use Smarty 3 specific features like template inheritance.
http://ilikekillnerds.com/2010/11/using-smarty-3-in-codeigniter-2-a-really-tiny-ci-library/
Integrating Smarty in CodeIgniter? It is a breeze!
The template system in CodeIgniter is very basic.
Follow these steps for Smarty 3 in CI 3:
Download CodeIgniter 3
Download Smarty 3 and put its content in 'application/third_party/smarty' folder
Create 'Custom_smarty.php' file in 'application/libraries' and add this code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH.'third_party/smarty/Smarty.class.php');
class Custom_smarty extends Smarty {
function __construct()
{
parent::__construct();
$this->setTemplateDir(APPPATH.'views/templates/');
$this->setCompileDir(APPPATH.'views/templates_c/');
}
}
?>
Create 'templates' & 'templates_c' folders inside 'application/views' folder
Create simple 'test.tpl' file in 'application/views/templates' folder
Open 'autoload.php' in 'application/config' folder and add:
$autoload['libraries'] = array('custom_smarty');
And inside a controller: $this->custom_smarty->display('test.tpl');
If you are working on localhost set the permissions: sudo chmod -R 777 templates_c. Otherwhise contact your hosting service, if you catch the error Unable to write file. First be sure templates_c folder exists.
Otherwise you can use another template engine like Twig.

Resources