skip to Main Content

Forgive the seeming lameness here. I’m working with a shared hosting with onnly access to cpanel and host are not willing to install composer nor PHPWord on my behalf. Is it possible to install PHPWord by just downloading the ZIP from github? Thanks

4

Answers


  1. You can use Composer locally and then upload the files to the server.

    I asked about this here: Using Composer locally then uploading files through FTP

    Basically, if you can’t run Composer on the server, use it locally, then copy the necessary files to the server.

    The reason you should use it is because it will download the dependencies for you, without you having to manually configure a load of stuff. That’s very much the point of Composer 🙂

    composer require phpoffice/phpword
    
    Using version ^0.13.0 for phpoffice/phpword
    
    ./composer.json has been created
    
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    
      - Installing pclzip/pclzip (2.8.2)
        Downloading: 100%         
    
      - Installing phpoffice/common (v0.2.6)
        Downloading: 100%         
    
      - Installing zendframework/zend-stdlib (2.4.13)
        Downloading: 100%         
    
      - Installing zendframework/zend-validator (2.4.13)
        Downloading: 100%         
    
      - Installing zendframework/zend-escaper (2.4.13)
        Downloading: 100%         
    
      - Installing phpoffice/phpword (v0.13.0)
        Downloading: 100%   
    
    Login or Signup to reply.
  2. Download The PHpWord Zip FIle From Here: https://github.com/PHPOffice/PHPWord/archive/develop.zip

    Source:: https://github.com/PHPOffice/PHPWord

    PHPWord requires the following extension:

    • PHP 5.3.3+
    • XML Parser extension
    • ZendEscaper component
    • ZendStdlib component
    • ZendValidator component
    • Zip extension (optional, used to write OOXML and ODF)
    • GD extension (optional, used to add images)
    • XMLWriter extension (optional, used to write OOXML and ODF)
    • XSL extension (optional, used to apply XSL style sheet to template )
    • dompdf library (optional, used to write PDF)

    Example Of basic usage of PHPWord library.
    https://github.com/PHPOffice/PHPWord

    Login or Signup to reply.
  3. Yes, I do it all the time. For PHPWord, I would download the zip file from GitHub and move the contents of the src folder to a directory called “libPhpOfficePhpWord”. You’ll then need a PHP class loader. I always use this for autoloading, provided the Classes are properly namespaced, which appears to be the case.

    $GLOBALS['class_path'] = array(__DIR__ . '/lib', __DIR__);
    
    // Set-up class_path superglobal variable using php include_path as basis
    if (!array_key_exists('class_path', $GLOBALS)) {
        $GLOBALS['class_path'] = array();
        foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
            // substitute __DIR__ path for '.' instead
            if ($path == '.') {
                array_push( $GLOBALS['class_path'], realpath(__DIR__) );
                continue;
            }
            array_push( $GLOBALS['class_path'], realpath($path) );
        }
    }
    
    if (!function_exists('import')):
    function import($package = '') {
        if (empty($package)) {
            trigger_error("Package path must be specified.", E_USER_ERROR);
        }
        $package_bits = explode('\', $package);
        $package_path = implode(DIRECTORY_SEPARATOR, $package_bits) . '.php';
        foreach ($GLOBALS['class_path'] as $path) {
            $file = $path . DIRECTORY_SEPARATOR . $package_path;
            if (file_exists($file)) {
                require_once($file);
                $entity_name = implode('\', $package_bits);
                if (!(class_exists($entity_name, false) ||
                    interface_exists($entity_name, false)
                    || trait_exists($entity_name, false))) {
                $caller = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
                trigger_error("Entity '" . $package . "' not found in file '" . $package_path . "' for import called in " .
                        $caller['file'] . " on line " . $caller['line'], E_USER_ERROR);
                }
                return;
            }
        }
    }
    endif;
    
    spl_autoload_register('import');
    

    Set your $GLOBALS[‘class_path’] to the location of the ‘lib‘ directory and be sure to use ‘use‘ as needed before attempting to instantiate PHPWord.

    Hope this helps!

    Login or Signup to reply.
  4. Here you can download PHPWord without composer:
    https://php-download.com/package/phpoffice/phpword

    On this site are all libraries from the composer network but you can download all of them without a composer installation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search