How do i user open office in zf2 project - zend-framework2

i have included the openoffice downloaded file to vendor folder, but i'm unable to access it and it when i do
$odf = new \Openoffice_Odf($templatePath, array('CLEAN_REMAINING_VARS' => true));
it gives me the error
Class 'Openoffice_Odf' not found

I think, you need to include it inside your script using include_path
require VENDOR_PATH.'OpenOffice/Odf.php';
or using a spl_autoloader

Related

Calling Another Project's Controller From A Project In The Same Solution (.NET Core )

There are 2 projects in the same solution. First project is a .NET Core project and it has all the codes(controllers, models etc.) related to packages. I need to get the information (id, name, description) of the packages and display it in the second project(.NET Core Web App with Razor). Is it possible to do it without changing the first project? I only want to show the package list on a single web page.
I tried calling the first project's controller but it didn't work. Maybe I missed a point. Any help is appreciated.
This requirement can be achieved, please see the gif image below.
Tips
If you want to call another project's controller from a project in the same solution, you need to make sure there is in HomeController in both project. I mean the name of any class should be unique in both projects.
Otherwise you will face the same issue like my homepage.
Test Code:
public List<PackageReference> GetPackageList5(string projectname)
{
List<PackageReference> list = new List<PackageReference>();
PackageReference p = null;
XDocument doc = XDocument.Load(_webHostEnvironment.ContentRootPath+ "/"+ projectname + ".csproj");
var packageReferences = doc.XPathSelectElements("//PackageReference")
.Select(pr => new PackageReference
{
Include = pr.Attribute("Include").Value,
Version = pr.Attribute("Version").Value
});
Console.WriteLine($"Project file contains {packageReferences.Count()} package references:");
foreach (var packageReference in packageReferences)
{
p = new PackageReference();
p.Version= packageReference.Version;
p.Include= packageReference.Include;
list.Add(packageReference);
//Console.WriteLine($"{packageReference.Include}, version {packageReference.Version}");
}
return list;
}
My Test Steps:
create two project, Net5MVC,Net6MVC
add project reference.
My .net6 project references a .net5 project. So in my HomeController (.net), I add below:
using Net5MVC.ForCore6;
using Net5MVC.Models;
Suggestion
When we reference the .net5 project in .net6 project, we can build success, but when we deploy it, it always failed. The reason is some file was multiple publish output files with the same relative path.
Found multiple publish output files with the same relative path:
D:\..\Net6\Net6\Net5MVC\appsettings.Development.json,
D:\..\Net6\Net6\Net6MVC\appsettings.Development.json,
D:\..\Net6\Net6\Net5MVC\appsettings.json,
D:\..\Net6\Net6\Net6MVC\appsettings.json.
And usually will add class library to current project, not add a web project.
As we know we can find packages info in .csproj file, so we need copy and paste .csproj file to publish folder.
I still recommend using the GetPackageList5 method above as an interface for your project, using HttpClient for requests.

FTP getbinaryfile by file extension?

I am using Net::FTP's getbinaryfile functionality to pull in a zip file with FTP. My system is not aware of the full file name, so I would simply like to search the folder for the zip file extension. Usually I would simply input the filename as *.zip. This does not seem to work.
ftp = Net::FTP.new(domain)
path = "#{Rails.root}/public/ftp/#{self.id}.zip"
ftp.getbinaryfile("*.zip", path)
I used the following code to return the zip file name in the FTP folder. Then using the same code as above, I was able to run getbinaryfile with the correct zip file name.
files = ftp.nlst("*.zip")
I use the following to get all zip files (I'm using SFTP but hopefully this will point you in the right direction)
Net::SFTP.start(domain, user, :password => 'pass') do |sftp|
sftp.dir.glob("/yourdirectory","*.zip").each do |file|
sftp.download!(file, "/local/spot")
end
end

Failed to open - Zend Framework

Warning: require_once(Zend/Application.php) [function.require-once]:
failed to open stream: No such file or directory in
D:\xampp\htdocs\obsessa\public\index.php on line 17
Fatal error: require_once() [function.require]: Failed opening
required 'Zend/Application.php'
(include_path='D:\xampp\htdocs\obsessa\library;.;D:/xampp/php/PEAR;D:/xampp/php/ZendFramework')
in D:\xampp\htdocs\obsessa\public\index.php on line 17
Hi Anyone help me on this ?
D:/xampp/php/PEAR;D:/xampp/php/ZendFramework
Should probably be:
D:/xampp/php/PEAR;D:/xampp/php/ZendFramework/library
The immediate problem is that your php include_path configuration is wrong. The reason is the way PSR-0 autoloading works. Your include path has two paths. If you want to load Zend\Application, then you need an include path that has a subdirectory called 'Zend'. In your case, D:/xampp/php/ZendFramework does not have that, you need D:/xampp/php/ZendFramework/library (which has a subdirectory named Zend, which has a file named Application.php)
But really, if you're doing ZF2, grab the skeleton application and use composer, just like the docs say, especially if you're new. composer is fantastic, and it's the preferred way to go. With composer, each application you write has its own installation of zf2. There are very few situations where you want your apps to rely on some globally-installed framework, which is the setup you're trying to do.
Please follow this step :
Please donwload the zend libray from zend official site
http://framework.zend.com/
Then paste donwloaded library in zend libray folder
Index.php file settings
//Ensure library/ is on include_path
set_include_path(
implode(PATH_SEPARATOR,
array(realpath(APPLICATION_PATH . '/../library'),
get_include_path(),)));
/** Zend_Application */
require_once 'Zend/Application.php';
please set index.php file as:
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(FILE) . '/../application'));
defined('LIBRARY_PATH')
|| define('LIBRARY_PATH', realpath(dirname(FILE) . '/../library'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
define('PUBLIC_PATH','http://'.$_SERVER['HTTP_HOST'].'/demo/public');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
set_include_path(implode(PATH_SEPARATOR, array(
realpath(DOCTRINE_PATH),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();

Upload document from local machine to server without using file input type

We are trying to upload a document from our local machine to server. We know that .NET browse control can be used for this but our requirement is to just have a button and call that as "Save Document". On click we know the path and also the document name, all we need to do is search the document in local machine (inside temp folder) and if the document is available then pick it and save it to our APP data folder on the server.
it's easy to achieve this using .NET borwse control but not sure how to do that same using normal button?
To find a file in a folder:
FileInfo file = Directory.GetFiles(#"c:\folder")
.FirstOrDefault(f => f.name = whatever);
To copy file:
File.Copy(file.FullName, targetPath, true);

Can't access File created by paperclip

Not sure what's the matter here :
file = Rails.root.join(Attachment.last.attachment.url(:original))
# => "/system/attachments/3/original/!my_awesome_pdf.pdf?1359735260"
Then I try and do this :
File.new(file, 'rb')
# => No such file or directory - /system/attachments/3/original/!my_awesome_pdf.pdf?1359735260
Why would that happen? I'm trying to be able to select the file to upload to GroupDocs.com
Ah the problem was that URI's will throw off Ruby from recognizing the name of the file. Removing the URI allows Ruby to open the file.

Resources