Using xDebug with Yii with custom folder structure - yii

The problem is that breaks don't work with files, that were moved out of webroot.
When all files were under the webroot all was OK:
z:\home\mysite.dev\www\framework\
z:\home\mysite.dev\www\protected\
z:\home\mysite.dev\www\index.php
Because of the specifics of the project, I have moved /framework and /protected out of webroot:
z:\common\yii\framework\
z:\home\mysite.dev\protected\
z:\home\mysite.dev\www\index.php
And so now the breaks on index.php in some /framework files are working, other don't. It seems to be I should make some tricky server mapping for xdebug, can anybody give me a hint?
xdebug settings from php.ini:
zend_extension="\usr\local\php5\ext\php_xdebug-2.2.0-5.3-vc9.dll"
xdebug.auto_trace = 0
xdebug.default_enable = 1
xdebug.idekey = "PHPSTORM"
xdebug.manual_url = "http://www.php.net"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_mode = "req"
xdebug.remote_port = 9000
Win7x64
Denwer3
PHPStorm 6.0.3

Related

How to deploy more than one spider that shares root directory with scrapyd?

I'm kinda new to scrapy and I'm building a project that plans to have multiple spiders. I read in the docs that multiple projects can exists on the same root directory of the folder that contains the scrapy.cfg file and then add the additional settings in the file.
I thought that it was a good idea, since each spider has a different logic and uses different pipelines (or same pipeline logic, but the process is different).
I built two spiders using this configuration:
main_folder:
scrapy.cfg
project1
items.py
pipelines.py
settings.py
...
spiders
spider1.py
project2
items.py
pipelines.py
settings.py
...
spiders
spider2.py
Using this configuration I ran scrapyd and could deploy the first spider from project1, but when trying to deploy the spider at project2 it gets deployed with the spider from project1 :(.
My scrapy.cfg looks like this:
[settings]
default = project1.settings
project2 = project2.settings
[deploy:project1]
url = http://localhost:6800/
project = project1
[deploy:project2]
url = http://localhost:6800/
project = project2
[scrapyd]
eggs_dir = eggs
logs_dir = logs
items_dir =
jobs_to_keep = 5
dbs_dir = dbs
max_proc = 0
max_proc_per_cpu = 4
finished_to_keep = 100
poll_interval = 5.0
bind_address = 0.0.0.0
http_port = 6800
username =
password =
debug = off
runner = scrapyd.runner
jobstorage = scrapyd.jobstorage.MemoryJobStorage
application = scrapyd.app.application
launcher = scrapyd.launcher.Launcher
webroot = scrapyd.website.Root
eggstorage = scrapyd.eggstorage.FilesystemEggStorage
[services]
schedule.json = scrapyd.webservice.Schedule
cancel.json = scrapyd.webservice.Cancel
addversion.json = scrapyd.webservice.AddVersion
listprojects.json = scrapyd.webservice.ListProjects
listversions.json = scrapyd.webservice.ListVersions
listspiders.json = scrapyd.webservice.ListSpiders
delproject.json = scrapyd.webservice.DeleteProject
delversion.json = scrapyd.webservice.DeleteVersion
listjobs.json = scrapyd.webservice.ListJobs
daemonstatus.json = scrapyd.webservice.DaemonStatus
I have two questions:
If I'm expecting to crawl many sites (lets say 20), is this a "good" way to handle different spiders that crawl different sites? Or my whole configuration is wrong and I should actually have two separated folders?
How I can deploy my second spider? I have tried different configurations in the scrapy.cfg file and ran scrapyd-deploy with different targets and projects, but I can't manage to get the spider2 deployed in scrapyd.

How to install php_java extension in wamp?

I have tried this in my php.ini file:
extension=php_java.dll
[java]
java.java = “C:/Program Files (x86)/Java/jdk1.7.0_03/bin/javaw.exe”
java.java_home = “C:/Program Files (x86)/Java/jre7”
java.class.path = “G:/wamp/bin/php/php5.3.9/ext/JavaBridge.jar”
java.library = “C:/Program Files (x86)/Java/jre7/bin/client/jvm.dll”
java.library.path = “G:/wamp/bin/php/php5.3.9/ext;C:/Program Files (x86)/Java/jre7/lib”
Now WAMP shows php_java extention, but php_info() does not shows java configurations.
use phpjavabridge to make communication between PHP and Java.
I have a youtube vid in French on it: https://www.youtube.com/watch?v=pHtgPrFOChQ

Phalcon Dev Tools - Builder doesn't knows where is the models directory

I'm getting "Builder doesn't knows where is the models directory" error when I run the phalcon all-models command in both Command Line and Phalcon Webtools.
Please let me know what am I missing?
My webtools.config.php content
define('PTOOLS_IP', '216.174.134.2');
define('PTOOLSPATH', '/var/www/html/vendor/phalcon/devtools');
My webtools.php content
use Phalcon\Web\Tools;
require 'webtools.config.php';
require PTOOLSPATH . '/scripts/Phalcon/Web/Tools.php';
Tools::main(PTOOLSPATH, PTOOLS_IP);
My config.ini content
[database]
adapter = Mysql
host = localhost
username = test
password = test
dbname = test
[application]
controllersDir = ../app/controllers/
modelsDir = ../app/models/
viewsDir = ../app/views/
pluginsDir = ../app/plugins/
libraryDir = ../app/library/
cacheDir = ../app/cache/
baseUri = /
[models]
metadata.adapter = "Memory"
I have change the modelsDir from ../app/models/ to /../app/models/ but still not working.
ANSWER FOUND:
Going to project root directory and type the command (instructions)
# phalcon all-models --directory /var/www/html/projec_name
I speficied the --directory which is the Base path on which project will be created.
Thank you colburton for helping me debug this problem. Much appreciated.
Going to project root directory and type the command (instructions)
# phalcon all-models --directory /var/www/html/projec_name
I speficied the --directory which is the Base path on which project will be created.
Thank you colburton for helping me debug this problem. Much appreciated.
In the options array you pass to the builder you need to add 'modelsDir' with the correct path.
On this page you can find a video with the webtools. There is a tab for "Configuration", where you can set them.
It is also located in the config.ini under app/config
I am using Phalcon 3. After generating a project with phalcon console tool I encountered this error.
There is an easy way out to resolve this issue. Change the following settings in app/config/config.ini if you have one.
[application]
controllersDir = app/controllers/
modelsDir = app/models/
viewsDir = app/views/
pluginsDir = app/plugins/
libraryDir = app/library/
cacheDir = ../cache/

Xdebug breaks Apache alias directives

I installed and configured Xdebug. Here is my configuration:
[Zend]
;zend_extension_ts = "D:\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll"
;zend_extension_manager.optimizer_ts = "D:\xampp\php\zendOptimizer\lib\Optimizer"
;zend_optimizer.enable_loader = 0
;zend_optimizer.optimization_level=15
;zend_optimizer.license_path =
; Local Variables:
; tab-width: 4
; End:
[XDebug]
;; Only Zend OR (!) XDebug
;zend_extension_ts="D:\xampp\php\ext\php_xdebug.dll"
zend_extension_ts = "D:\xampp\php\ext\php_xdebug-2.2.4-5.2-vc9.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="D:\xampp\tmp"
I have also checked the Xdebug installation according to this. It is working fine.
The problem is that my Apache alias directive is not working after Xdebug is installed. I have the following configuration in D:\xampp\apache\conf\httpd.conf
Alias /example "D:\xampp\htdocs\example\html"
Alias /example2 "D:\xampp\htdocs\example2\html"
Before I installed Xdebug, they are working fine. I could browse localhost/example and localhost/example2. But after I have installed Xdebug, I could not browse them. They are redirecting to www.localhost.com/example and www.localhost.om/example2.
When I removed the Xdebug configuration, they are back to the running state.
I'm using XAMPP 1.6.7.
[UPDATE]
I just noticed Xdebug (php_xdebug.dll) comes with XAMPP by default. However, when I used it, my localhost is completely gone.
zend_extension_ts="D:\xampp\php\ext\php_xdebug.dll"
;zend_extension_ts = "D:\xampp\php\ext\php_xdebug-2.2.4-5.2-vc9.dll"

Using Compass on Heroku: /tmp for stylesheets remotely and locally

I'm currently using Compass with Heroku using this configuration recommended on the Heroku knowledge base. Heroku has a read-only file system, and so the compiled stylesheets need to be stored in /tmp. This works fine remotely on Heroku; locally, however, Rails expects to find stylesheets in /public/stylesheets (when called through = stylesheet_link_tag 'screen.css', :media => 'screen, projection').
In order to solve the problem, I have created symbolic links in /public/stylesheets using ln -s tmp/stylesheets/screen.css public/stylesheets/screen.css and that seems to work.
Is there a way to solve this problem without using symbolic links, perhaps by changing some configuration in Rails? I've poked around without much success.
Here is my config/initializers/compass.rb:
require 'compass'
require 'compass/app_integration/rails'
Compass::AppIntegration::Rails.initialize!
# Required for Heroku:
require 'fileutils'
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets"))
Compass::AppIntegration::Rails.initialize!
Rails.configuration.middleware.delete('Sass::Plugin::Rack')
Rails.configuration.middleware.insert_before('Rack::Sendfile', 'Sass::Plugin::Rack')
Rails.configuration.middleware.insert_before('Rack::Sendfile', 'Rack::Static',
:urls => ['/stylesheets'],
:root => "#{Rails.root}/tmp")
And here is my config/compass.rb:
project_type = :rails
project_path = Compass::AppIntegration::Rails.root
# Set this to the root of your project when deployed:
http_path = "/"
# Necessary for Heroku (original commented out:
css_dir = 'tmp/stylesheets'
#css_dir = "public/stylesheets/compiled"
sass_dir = 'app/views/stylesheets'
environment = Compass::AppIntegration::Rails.env
Any help would be greatly appreciated.
I was actually just about to set up Compass with our Rails application, which is hosted on Heroku, so cheers for giving me an excuse to work through this. :)
The answer is simple:
Modify 'config/compass.rb':
project_type = :rails
project_path = Compass::AppIntegration::Rails.root
http_path = "/"
environment = Compass::AppIntegration::Rails.env
if environment == 'production'
css_dir = "tmp/stylesheets"
sass_dir = "app/views/stylesheets"
else
css_dir = "public/stylesheets"
sass_dir = "app/stylesheets"
end
Then modify 'config/initializers/compass.rb':
require 'compass'
require 'compass/app_integration/rails'
Compass::AppIntegration::Rails.initialize!
require 'fileutils'
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets"))
environment = Compass::AppIntegration::Rails.env
if environment == 'production'
Compass::AppIntegration::Rails.initialize!
Rails.configuration.middleware.delete('Sass::Plugin::Rack')
Rails.configuration.middleware.insert_before('Rack::Sendfile', 'Sass::Plugin::Rack')
Rails.configuration.middleware.insert_before('Rack::Sendfile', 'Rack::Static',
:urls => ['/stylesheets'],
:root => "#{Rails.root}/tmp")
end
... and voila, you're good.
ok, I'm a big heroku and compass fan myself so i've been through this many times
Heroku's docs, whilst giving correct information, provide poor advice in this instance.
When using compass, the best thing to do, 99.999% of the time is turn it off in production mode.
This means that you compile your stylesheets on your development machine and then add them to your git repo before pushing to heroku.
You will suffer a reasonably sizeable performance hit if you allow compass to compile on the server.
So here's what I do:
You should have a config.ru file at the base of your app. Open it and add the following:
require 'sass/plugin/rack'
use Sass::Plugin::Rack
Sass::Plugin.options[:never_update] = true
You can then remove quite a lot of the code from your initializer (especially the part where you unload Sass::Plugin::Rack). Additionally you will want to remove the if statement from compass.rb in config folder
Think about it, why would you want Sass to compile a stylesheet on the server? It just eats up processing power. Hope this helps,
EDIT::
PS - I should add that you will need to run compass watch from the command line now in order to get your stylesheets to compile in your dev environment
The recommended Heroku configuration will also work locally.
Removed the second 'Compass::AppIntegration::Rails.initialize!' from config/initializers/compass.rb, you only need it once.
Ensure your scss files are in 'app/views/stylesheets'
On both local and production servers the stylesheets will be compiled to tmp/stylesheets, and a request to /stylesheets will resolve to tmp/stylesheest. No need for two separate configurations.