yii camel case class filenames in linux - yii

I have created my first Yii application. I used Gii Model generator for creating models.For example, I created my Model Class name as ProductManager and in the CURD generator the Controller ID as productManager. Everything was working fine in my XAMPP server, but when I uploaded it to my online linux hosting.
I got the php include file error. It is looking for models/Productmanager.php, but when I changed the file name from ProductManager.php to Productmanager.php there is error in another model file.
Also I have to use the Camel case URL name for Controllers in the online server. Can anyone please explain how to configure the Gii , so that it will work without any problems in linux hosting servers.

Gii uses the name of your table to create the model name. Did you name your table productmanager or product_manager? The latter will allow Gii to automatically create a model with the name ProductManager (CamelCase), else it will be Productmanager.
Hope this helps.

Related

Hybris: cannot find CMSSite associated with current URL

I created a new Hybris extension using one of the given templates.
The build was successful and I am able to start the server, too.
But when opening the weblink from the HAC I get the error "Cannot find CMSSite associated with current URL".
Are there suggestions to solve or investigate this issue?
You need to use hosts file mappings or use the site-ID parameter to avoid a 500 error.
Please follow these link
https://wiki.hybris.com/display/accdoc/Just+One+Storefront
https://help.hybris.com/6.3.0/hcd/8ae0711f86691014877ae05249b2f5ac.html (Hybris 6)
If you have administrator rights, it is a good idea to add the following entries in your host file.
127.0.0.1 hybris.local [Example]
The etc hosts modification allows the accelerator to identify sites (CMSSites) from the url. This makes the URL neat and clean.
After host file change, You can access the site like this
http://hybris.local:9001/yacceleratorstorefront/
If you don't do this, the sites would need to be identified with an additional request parameter like this
http://localhost:9001/yacceleratorstorefront/?site=hybris&clear=true
Error "Cannot find CMSSite associated with current URL".
This is because you are not telling hybris which site you want to access.
There are three ways to do that
Simply pass your siteID as a request parameter(?site=SiteID) in your first request which helps the Hybris to understand which site you are trying to access. Let's say I'm trying to access powertools site then URL would be
https://localhost:9002/yacceleratorstorefront?site=powertools
Access site with siteID as DNS name. You can make 127.0.0.1 host with <siteID>.local. Let's say I want to access a powertools (It's CMSSite id for powertools), then add an entry like 127.0.0.1 powertools.local in your host file and then access your site using http://powertools.local:9001/yacceleratorstorefront/ instead of localhost
Add a new regular expression of your choice in the urlPatterns of your CMSSite. So that you can access your site as you want. Let's say I want to access site using localhost URL only and without passing ?site=powertools ever. So I need to add a new regex like (?i)^https?://[^/].*$ to urlPatterns of powertools CMSSite. Now I can directly open powertools site using https://localhost:9002/yacceleratorstorefront/
You can do that using Impex as well
$siteUid=mysite
# CMS Site
INSERT_UPDATE CMSSite ; uid[unique=true] ; urlPatterns ;
; $siteUid ; (?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=$siteUid)(|\&.*)$,(?i)^https?://$siteUid\.[^/]+(|/.*|\?.*)$,(?i)^https?://[^/].*$ ;
Find the detailed answer here
In addition to the host entry, make sure to add the appropriate regular expression for your website.
The CMS site has an attribute called urlPatterns. This is a list of regular expressions that the website CMS filters match to determine which storefront a user is trying to access.
The simplest thing is to add a further regular expression to the CMS site like the one below:
(?i)^https?://[^/]*/yacceleratorstorefront((?![\?\&]site=).)*
At run time, you can can do it in the hybris Management Console(hMC). Navigate to WCMS Website Your Site Name Properties tab and edit URL Patterns section.
To make the change permanent, add the appropriate code to the CMS site setup ImpEx script run during the project data phase of initialization e.g. for electronics storefront
# CMS Site
UPDATE CMSSite;uid[unique=true];urlPatterns;
;electronics;(?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=electronics)(|\&.*)$,(?i)^https?://electronics\.[^/]+(|/.*|\?.*)$,(?i)^https?://api\.hybrisdev\.com(:[\d]+)?/rest.*$,(?i)^https?://[^/]*/yacceleratorstorefront((?![\?\&]site=).)*;
This issue usually comes up if the server was started with unsatisfied spring bean dependencies. Please check your server startup log to confirm which particular bean or beans failed to initialise.

How to specify application / domain name in a deployable zip?

I am building a Mule domain using Maven which works fine, except the zip file it creates is named MyDomain-1.0.0.0.zip
Mule (community edition) will bring up this domain with a domain name of MyDomain-1.0.0.0 when deployed.
I want the name to be MyDomain. I cannot find a way of specifying the domain name which is used - it seems Mule always uses the zip file name.
The reason i want to do this is because the applications in the domain are coded to use MyDomain, and obviously fail if the domain isnt named as such.
When running in AnyPoint, the domain is named after the project name, and I dont want to have to change the project name in Anypoint to include the version number.
Is this possible please? the only way round it ive found is to rename the zip file to MyDomain.zip, which I dont want to do since I want releases to have unique zip filenames (but keep the same domain name)
You can use the finalName child tag of build i.e:
<build>
<finalName>myapp</finalName>
</build>
Use the domain including the version. It would allow you to have apps run in different versions of a domain without the requirement of a turn-key switch to a new domain version.
So, create a project called 'myDomain' (you probably have that) and set in the mule-project.xml of your domain that the domain is 'myDomain-1.0.0'. This would allow the versioning of both the domains and the api referencing them to be handled by maven versioning and not force any weird and ugly things like using finalName (which forfeits all SNAPSHOT and versioning capabilities).
Also, you are now free to develop a myDomain2 and let it propagate the 'myDomain-2.0.0' domain. The reference of every app to it's domain in the pom.xml will be just as it's suppose to be. An app will just request 'myDomain-1.0.0' from the .m2 maven repo and it will find it.

Include YII Application in a script

I would like to create a PHP script which is called via CLI. And I would like that script to have access to the Yii application. Therefore I created a file called (script.php)
// file: script.php
ob_start();
include "index.php"
ob_clean();
echo "This is my script !";
I had to include the *ob_start* and *ob_clean* as if I didn't the layout of the application was being render.
Is this the right way to do this? Or should I be doing something else?
If you want to deal with php console, it is highly recommended to use CConsoleCommand. You can create your file which must act in console in protected/commands path. So your class would be something like below:
class TestConsoleCommand extends CConsoleCommand{}
You can implement your php codes into your functions, but note that the most important method in your class would be init() method. Once your consoleCommand runs, this method will be called.
another important note is that, THE CONFIG OF CONSOLE COMMAND IS DIFFERENT WITH NON-CONSOLE. It means that while your ordinary Yii application is running, you are using main.php config file, which is situated in protected/config/main.php. In order to access your models and database config ... in your Yii ConsoleApp, You must fulfill the console.php config file which is situated in protected/config/console.php.
You can configure your database connection in this file, which you want to access it, while your ConsoleApp is running. You can also import all your classes you need to interact.
Some useful links and documents:
CConsoleCommand - represents an executable console command
The Definitive Guide to Yii - Console Applications
I hope it helps :)

Simulate dynamically subdomains with .htaccess with a different database but same code base in Drupal

Sorry about my english level.
I researched so much, and i found that can i use ".htaccess" to get redirection to subdomain folder and this is OK.
In Drupal i need to create a folder for each subdomain in "/sites/sub.example.com/" and copy "default.settings.php" from default folder "/sites/default/default.setting.php" and rename it to "settings.php", after that, enable "$databases" variable in the same file, when it's done, i need to add a wildcard and modify "hosts" file.
Well, i should "automate" all this, but i don't know if it's is more hard because it's important hold the server safety with writing permissions or try another way, someone could advise me.
Im working on OSX and Drupal 7.x (recent release)
Thank you very much.
For each site that you want to use separate database, create own sites/ directory with settings.php. For example, if you want to have one database for example.com, another one for sub1.example.com and third one for sub2.example.com, all using same code base, setup your files like this:
sites/example.com/settings.php
sites/sub1.example.com/settings.php
sites/sub2.example.com/settings.php
each settings.php using different database credentials.
Read more here - https://drupal.org/documentation/install/multi-site
Also, if you want to automate this and if there is supposed to be bigger number of sites to be managed, consider deploying aegir - http://www.aegirproject.org.
I hope I understood your question correctly.

How can I copy a YII project to another server?

I have got a YII website and I would like to make a copy from it to another domain on nginx server.
I just tried to copy it, but it doesn't working. It looks like it don't use my htaccess?
I know when I make I new project I have to install it. Is there any copy-er for YII?
The probable reason it is not working is because you have to change the location of the entry script in the index.php for the correct location for the yii main folder.
Try doing this :
Try making a new Yii webapp in that location and check that it
works.
Now copy the index.php file from that folder and then put it in your
main webapp.
If the site is still giving errors then check if the database connection is consistent and check that the server has proper write access to the main webapp folder.
Hope this helped.
Regards,
Yii is just made of files and (optionally) a database. Provided you copy both to the new server it will just work. Yii also requires server write permissions on /protected/runtime and /assets.
Make sure you're copying hidden (start with .) files too. You could use git for this and clone it into the new server.
It was something with the server. We use webmin ot that server and I hade to rewrite the config of this domain manually, after that it works great.